Page tree
Skip to end of metadata
Go to start of metadata

The Compare  field expression compare the values of two stored fields (using EQ, NE, and various inequality tests) resulting in a new field containing a Boolean (true/false) outcome.  For instance, the following examples take Factbook Olympic Medal search results and test to see if the number of gold medals is the same as the number of silver medals for each result. 

Available Functions (See here ):

  • EQ – Equal To (==)

  • GT – Greater Than (>)

  • LE – Less Than or Equal To (<=)

  • LT – Less Than (<)

  • NE – Not Equal To (<> or !=)


QueryRequest request = new QueryRequest("*:*)");
request.addField(new Compare(Compare.Operator.EQ, new StoredField("gold_i"), new StoredField("silver_i"),"Gold=Silver?"));
// ... (Perform Search)

REST Syntax:


  • FUNCTIONNAME - any of the available field comparison functions specified above. (EQ, NE, etc.)
  • FIELDEXPRESSION1 - First field to be compared.
  • FIELDEXPRESSION2 - Second field to be compared.
  • ALIAS - New field name for the result of the comparison.


&fields=EQ("gold_i","silver_i") as "Gold=Silver?"
  • No labels