Search Comparator & Apache Lucene

1 minute read

Published:

This content is based on the issue I faced while doing analyzing with a search comparator for queries associated with the HL7 message field. (but this is applicable for sample scenarios whether the Lucene queries can be used.

Apache Lucene is one of the best Query languages to search queries quickly but It will fetch the details from only one table specified by the user. check out 1 for further clarification.

This blog post is just to show some equivalence values to be denoted for some generic search comparators.

Search Comparator

  1. = (equals) this can be easily expressed by putting : instead of =.
  2. <,>,<=, >= these are applicable for number types such as Integer, Long and Double. For using this we have to define the maximum and minimum of the language-specific to those types.
    • For Java, it can be obtained by Long.MAX_VALUE for Maximum long
    • For Javascript, we can’t obtain specific but we can defined Values obtained from Java. In certain cases we can use “Number.Maximum” but that is not specific to any number type. Like these, we can obtain maximum and minimum and make use them for boundaries
    • For < , it can be done by valueType : { MIN_VALUE TO yourValue }, use the [ bracket for <=.
    • For >, it can be done vice versa that is valueType : { yourValue TO MAX_VALUE } , here too use [ bracket of >=
  3. contains, this can be done by adding * to the relative data values check 1 for the clear explanation regarding this.

References

  1. https://lucene.apache.org/core/2_9_4/queryparsersyntax.html