sharepoint-2013sharepoint-search

How to use > and < operators in SharePoint search API?


I am using SharePoint Search API and referring link SharePoint Search REST API overview. I want to use property operators. Please refer 'Property operators that are supported in property restrictions' section in link Keyword Query Language (KQL) syntax reference

I am forming query as http://server/_api/search/query?querytext='AmountCurrency > 10.50'&selectproperties='Title,Author'

Similarly http://server/_api/search/query?querytext='AmountNumber < 20.50'&selectproperties='Title,Author'

In above queries AmountCurrency and AmountNumber are managed properties for Currency column and Number column respectively. But search api not returing any row. For me : and = operators are working fine. How to use greater than and less than operators in search API?


Solution

  • Got it. It is due to the managed property type. Following are the available types when we create managed properties.

    When managed property gets created automatically for site columns, the default type is Text. While creating managed property manually only Search Service Application administrator can choose any type. All other users can choose either Text or Yes/No.

    I am not SSA Administrator. So I have used default unused managed properties. Please refer https://technet.microsoft.com/en-us/library/jj219667.aspx#Anchor_8. Used RefinableDecimal00 and RefinableDecimal01 and mapped appropriate crawled property to them. Now everything is working fine