Liking cljdoc? Tell your friends :D

Clojars Project cljdoc badge Tests

lucene-query-parsing

Library to parse Lucene queries and build query parsers in the data-driven fashion.

Quickstart

Dependencies:

{:deps
 {lt.jocas/lucene-query-parsing {:mvn/version "RELEASE"}}}

Code:

(require '[lucene.custom.query :as q])

;; Parse queries
(q/parse "foo bar baz")
;; => #object[org.apache.lucene.search.BooleanQuery 0x650526d1 "foo bar baz"]

(q/parse "*foo bar baz" :classic {:allow-leading-wildcard true} "field-name")
;; => #object[org.apache.lucene.search.BooleanQuery 0x3218294 "field-name:foo field-name:bar field-name:baz"]


(require '[lucene.custom.query-parser :as query-parser])

;; Create query parser
(query-parser/create :classic {:allow-leading-wildcard true})
;; =>
;; #object[org.apache.lucene.queryparser.classic.QueryParser
;;         0x36df3ba2
;;         "org.apache.lucene.queryparser.classic.QueryParser@36df3ba2"]

Available Query Parsers

Currently, 5 Lucene query parsers are supported:

These query parsers can be further configured with these parameters that were extracted from the Lucene source code. The configuration options compatibility table for each supported query parser:

:option:classic:complex-phrase:simple:standard:surround
:allow-leading-wildcardtruetruefalsetruefalse
:auto-generate-multi-term-synonyms-phrase-querytruetruetruefalsefalse
:auto-generate-phrase-queriestruetruefalsefalsefalse
:date-resolutiontruetruefalsetruefalse
:default-operatortruetruetruetruefalse
:default-operatortruetruetruetruefalse
:default-operatortruetruetruetruefalse
:determinize-work-limittruetruefalsefalsefalse
:enable-graph-queriestruetruetruefalsefalse
:enable-position-incrementstruetruetruetruefalse
:enable-position-incrementstruetruetruetruefalse
:fuzzy-min-simtruetruefalsetruefalse
:fuzzy-prefix-lengthtruetruefalsetruefalse
:in-orderfalsetruefalsefalsefalse
:localetruetruefalsetruefalse
:multi-term-rewrite-methodtruetruefalsetruefalse
:phrase-sloptruetruefalsetruefalse
:split-on-whitespacetruetruefalsefalsefalse
:time-zonetruetruefalsetruefalse

Defaults

Default values for every Lucene query parser configuration option:

:option:classic:complex-phrase:simple:standard:surround
:allow-leading-wildcardfalsefalse false
:auto-generate-multi-term-synonyms-phrase-queryfalsefalsefalse
:auto-generate-phrase-queriesfalsefalse
:date-resolution
:default-operatorORORshouldOR
:default-operatorORORshouldOR
:default-operatorORORshouldOR
:determinize-work-limit1000010000
:enable-graph-queriestruetruetrue
:enable-position-incrementsfalsefalsetruefalse
:enable-position-incrementsfalsefalsetruefalse
:fuzzy-min-sim2.02.0 2.0
:fuzzy-prefix-length00 0
:in-order true
:localeenen en
:multi-term-rewrite-methodCONSTANT_SCORE_REWRITECONSTANT_SCORE_REWRITE CONSTANT_SCORE_REWRITE
:phrase-slop00 0
:split-on-whitespacetruetrue
:time-zone

In case you're lost: those cells that in the compatibility table states true but in the default values is empty mean that the default value is nil.

For further details consult the Lucene docs.

License

Copyright © 2022 Dainius Jocas.

Distributed under The Apache License, Version 2.0.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close