Liking cljdoc? Tell your friends :D

clucie.query


FormParsablecljprotocol

parse-formtclj

(parse-formt form options)
source

parse-formclj

(parse-form form
            &
            {:keys [analyzer mode]
             :or {analyzer (analysis/standard-analyzer) mode :query}})

Parses form, returning an org.apache.lucene.search.Query.

The form is parsed according to the following rules:

org.apache.lucene.search.Query => as is [query1 query2] => query1 AND query2 #{query1 query2} => query1 OR query2 {:field "value"} => query(field:value)

Options:

{:analyzer An org.apache.lucene.analysis.Analyzer instance used for building query from string, default (clucie.analysis/standard-analyzer). :mode Changes the behavior of parsing string, default :query. <:query|:phrase-query|:wildcard-query|:qp-query>}

You can extend the behavior of parse-form by implementing parse-formt of FormParsable protocol. For example,

(extend-protocol clucie.query/FormParsable java.util.regex.Pattern (parse-formt [re {:keys [key]}] (org.apache.lucene.search.RegexpQuery. (org.apache.lucene.index.Term. (stringify-value key) (.pattern re)))))

adds a new rule that builds an org.apache.lucene.search.RegexpQuery from a regexp.

Parses form, returning an org.apache.lucene.search.Query.

The form is parsed according to the following rules:

  org.apache.lucene.search.Query => as is
  [query1 query2] => query1 AND query2
  #{query1 query2} => query1 OR query2
  {:field "value"} => query(field:value)

Options:

  {:analyzer  An org.apache.lucene.analysis.Analyzer instance used for building
              query from string, default (clucie.analysis/standard-analyzer).
   :mode      Changes the behavior of parsing string, default :query.
              <:query|:phrase-query|:wildcard-query|:qp-query>}

You can extend the behavior of parse-form by implementing parse-formt of
FormParsable protocol. For example,

  (extend-protocol clucie.query/FormParsable
    java.util.regex.Pattern
    (parse-formt [re {:keys [key]}]
      (org.apache.lucene.search.RegexpQuery.
       (org.apache.lucene.index.Term. (stringify-value key) (.pattern re)))))

adds a new rule that builds an org.apache.lucene.search.RegexpQuery from a
regexp.
sourceraw docstring

postwalkclj

(postwalk f query)

Performs a depth-first, post-order traversal of query. Calls f on each sub-query, uses f's return value in place of the original.

Performs a depth-first, post-order traversal of query. Calls f on each
sub-query, uses f's return value in place of the original.
sourceraw docstring

postwalk-democlj

(postwalk-demo query)

Demonstrates the behavior of postwalk by printing each query as it is walked. Returns query.

Demonstrates the behavior of postwalk by printing each query as it is walked.
Returns query.
sourceraw docstring

prewalkclj

(prewalk f query)

Like postwalk, but does pre-order traversal.

Like postwalk, but does pre-order traversal.
sourceraw docstring

prewalk-democlj

(prewalk-demo query)

Demonstrates the behavior of prewalk by printing each query as it is walked. Returns query.

Demonstrates the behavior of prewalk by printing each query as it is walked.
Returns query.
sourceraw docstring

walkclj

(walk inner outer query)

Traverses query. inner and outer are functions. Applies inner to each sub-query of query, building up a query of the same type, then applies outer to the result.

Traverses query. inner and outer are functions. Applies inner to each
sub-query of query, building up a query of the same type, then applies outer
to the result.
sourceraw docstring

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

× close