Hi, Zach:

Yes, you can use numeric and other typed values with string or structured 
search.  The steps:

1.  Create a range index on the element with the appropriate datatype.
2.  Create a range constraint in the query options that names the range index.
3.  Express the comparison in string or structured search.

For instance, assuming an xs:int range index on an <val> element in the 
documents
containing some values greater than 3:

let $options :=
<options xmlns="http://marklogic.com/appservices/search";>
  <constraint name="val">
   <range type="xs:int" facet="false">
   <element ns="" name="val"/>
   </range>
  </constraint>
</options>
return search:search('val GT 3', $options)

Range indexes and constraints are also important for sorting and facet 
aggregation.

The documentation has more detail:

http://docs.marklogic.com/guide/search-dev/search-api#id_68918
http://docs.marklogic.com/search:search#opt-constraint


Hoping that helps,


Erik Hennum

________________________________
From: [email protected] 
[[email protected]] on behalf of Dunlap, Zachariah 
[[email protected]]
Sent: Friday, January 04, 2013 8:54 AM
To: [email protected]
Subject: [MarkLogic Dev General] Using LT & GT Operators in search:search to 
compare numerical values

Is it possible to use the built in LT (less than) & GT (greater than) operators 
in Search with numerical values?

These built in operators seem to expect strings as noted here: 
http://docs.marklogic.com/guide/search-dev/search-api#id_44520

Is there a way we can tell MarkLogic that the values for a particular set of 
fields are numbers not strings?

Thank you,

Zach

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to