Lucene Query Language
Reminder: you can left-scroll and right-scroll the long code blocks
Introduction
Lucene is a free and open-source information retrieval library supported by the Apache Software Foundation.
It powers the Apache Solr search engine as well as Elasticsearch.
In both of these engines, you sometimes want to make queries directly to Lucene. The following presents the Lucene Query Language expressions that I use the most.
General operators
+
- The term must be present
-
- The term must be absent
_exists_
- The field must not be empty
^
- Boosts the term
AND
,OR
,NOT
(also noted&&
,||
,!
)- Boolean operators
/regx/
- Regular expressions
[xx TO yy ]
- Inclusive range
{xx TO yy}
- Exclusive range
1 | _exists_:author |
Various examples
Numbers and numeric operators
1 | age:30 |
Dates
1 | date:2012-01-01 |
Strings
1 | author:"John Smith" |
Conclusion
That’s it for the Lucene Query Language expressions that I use the most. Which ones do you use the most ?
Let me know in the comments below 😉
See you soon !
Keep learning !
Written on Tue Oct 30th 2018, 8:28 GMT+00:00.
Last updated on Tue Oct 30th 2018, 8:28 GMT+00:00.