Reputation: 77
Can anyone of you please suggest some solution for the following questions?
What is the correct format of if query in solr. I want to check if a particular fieldvalue is greater than a constant For ex: if((field1>0), field1, field2) is this possible in solr? and also can we do the same with date field. by comparing two dates?
Upvotes: 1
Views: 3643
Reputation: 1114
Solr ( and Lucene in general) are documents based. It means the unit of information is a single document ( composed by a set of fields). You search and you get back documents. To search for documents that have the value of a field less than a constant you can use range queries[1] :
field1:[* TO 500] This is equivalent to " return me all the documents where field1 has a value < than 500. The same can be done for dates.
Given that, I don't get the "conditional" part of your request, but Solr offers a conditional function query, that could be of use[2]
[2] https://lucene.apache.org/solr/guide/6_6/function-queries.html#FunctionQueries-AvailableFunctions
Upvotes: 1