You are here

Search validation and blank fields

[Forum topic copied over from another site, including original posting and all replies]

[Initial post]

We had recently had changed our Structured Search Validation from OR’ing of terms to AND’ing for LEXS 2.0. So that all search elements if present must be valid. However, one use case that we hadn’t considered is if a client sends blank fields. For our LEXS 2.0 version we reverted back to OR’ing of Structured Search fields for Validating to cover this use case.

 

Going forward for LEXS 3.X how should the following use cases be handled when QueryMatch=exact and LocatPostalCode is blank.


Case 1: XML Snippet

 

        <lexs:StructuredQuery>
            <lexs:DigestQueryStatement
>
                <lexs:DigestQueryField
>
                    <nc:Location s:id="L-1-1"
>
                        <nc:LocationAddress
>
                            <nc:StructuredAddress
>
                                <nc:LocationStreet
>
                                    <nc:StreetFullText>123 Main St.</nc:StreetFullText
>
                                </nc:LocationStreet
>
                                <nc:AddressSecondaryUnitText>Apt. A,#2</nc:AddressSecondaryUnitText
>
                                <nc:LocationCityName>San Francisco</nc:LocationCityName
>
                                <nc:LocationStateName>CA</nc:LocationStateName
>
                                <nc:LocationCountryName>US</nc:LocationCountryName
>
                                <nc:LocationPostalCode></nc:LocationPostalCode
>
                            </nc:StructuredAddress
>
                        </nc:LocationAddress
>
                    </nc:Location>

                </lexs:DigestQueryField>
                <lexs:QueryMatch>exact</lexs:QueryMatch
>
            </lexs:DigestQueryStatement
>
        </lexs:StructuredQuery>

 

So if the user intends to search for an ADDRESS but then the application sends the zipcode that is blank,or other fields filled in with blank values.

 

I currently I see QueryMatch enumeration as:  fuzzy,exact,gt,ge,lt,le,wildcard.


Would any of these effect how the search is validated, and thus executed.


[1st reply]

There are two separate issues here.

 
1) Only one query field is allowed per DigestQueryStatement, so to query on all the fields listed below there would have to be 6 DigestQueryStatements, not just the one.
 
2) If the query includes a blank query field, that is really asking for data items where that element has no data; so in the example below the query is looking for addresses in a particular city/state/street that have no zip code.  I doubt that is what is intended.  I would assume the intent was that the user just didn't supply data for that field and some client application transformed that into a blank element.  So the client should essentially strip out empty fields from the user query and not create empty elements in the structured query.  Note that in LEXS prior to 3.1.4 there are some mandatory elements, such as in Organization, where a null element may need to be provided so there remains only one "value" provided per query statement; but those should include an xsi:nil attribute along with empty contents.  Section 6.2 of the user guide shows that case.

[2nd reply]

Are you saying that

  <lexs:StructuredQuery>
   <lexs:DigestQueryStatement>
    <lexs:DigestQueryField>
     <lexsdigest:EntityPerson>
      <lexsdigest:Person>
       <nc:PersonName>
        <nc:PersonGivenName>BOB</nc:PersonGivenName>
        <nc:PersonSurName>JONES</nc:PersonSurName>
       </nc:PersonName>
      </lexsdigest:Person>
     </lexsdigest:EntityPerson>
    </lexs:DigestQueryField>
    <lexs:QueryMatch>exact</lexs:QueryMatch>
   </lexs:DigestQueryStatement>
  </lexs:StructuredQuery>

should be:

  <lexs:StructuredQuery>
   <lexs:DigestQueryStatement>
    <lexs:DigestQueryField>
     <lexsdigest:EntityPerson>
      <lexsdigest:Person>
       <nc:PersonName>
        <nc:PersonGivenName>BOB</nc:PersonGivenName>
       </nc:PersonName>
      </lexsdigest:Person>
     </lexsdigest:EntityPerson>
    </lexs:DigestQueryField>
    <lexs:DigestQueryField>
     <lexsdigest:EntityPerson>
      <lexsdigest:Person>
       <nc:PersonName>
        <nc:PersonSurName>JONES</nc:PersonSurName>
       </nc:PersonName>
      </lexsdigest:Person>
     </lexsdigest:EntityPerson>
    </lexs:DigestQueryField>
    <lexs:QueryMatch>exact</lexs:QueryMatch>
   </lexs:DigestQueryStatement>
  </lexs:StructuredQuery>


[3rd reply]


Almost.

 
Each <lexs:DigestQueryField> must be followed by corresponding <lexs:QueryMatch>, so you could request exact match on nc:PersonGivenName and wildcard match on nc:PersonSurName.
 
Every lexs:DigestQueryStatement must contain one lexs:DigestQueryField and one lexs:QueryMatch.
 
Here is a code snippet (search on Bob Jones):
<lexs:StructuredQuery>
    <lexs:DigestQueryStatement>
        <lexs:DigestQueryField>
            <lexsdigest:EntityPerson>
                <lexsdigest:Person>
                    <nc:PersonName>
                        <nc:PersonGivenName>Bob</nc:PersonGivenName>
                    </nc:PersonName>
                </lexsdigest:Person>
            </lexsdigest:EntityPerson>
        </lexs:DigestQueryField>
        <lexs:QueryMatch>exact</lexs:QueryMatch>
    </lexs:DigestQueryStatement>
    <lexs:DigestQueryStatement>
        <lexs:DigestQueryField>
            <lexsdigest:EntityPerson>
                <lexsdigest:Person>
                    <nc:PersonName>
                        <nc:PersonSurName>Jones</nc:PersonSurName>
                    </nc:PersonName>
                </lexsdigest:Person>
            </lexsdigest:EntityPerson>
        </lexs:DigestQueryField>
        <lexs:QueryMatch>exact</lexs:QueryMatch>
    </lexs:DigestQueryStatement>
</lexs:StructuredQuery>

For details see Section 6.2-Structured Query of the User Guide in the LEXS distribution (docs/LEXS 3.1 User Guide-rev*.pdf). LEXS 3.1 distribution also includes a number of more complex search examples supplied in xml/SR-samples directory of the distribution package.