From 9118ea5ec63b15b6f6c930ae3ccd6885b0d34300 Mon Sep 17 00:00:00 2001 From: sadiq Date: Thu, 22 Aug 2024 23:05:16 +0330 Subject: [PATCH] DOCS: Fix match query import path & link in index.md --- README.md | 4 +-- docs-src/docs/index.md | 8 +++--- docs-src/docs/match_query.md | 4 +-- docs/index.html | 8 +++--- docs/match_query/index.html | 4 +-- docs/search/search_index.json | 2 +- docs/sitemap.xml | 46 +++++++++++++++++----------------- docs/sitemap.xml.gz | Bin 361 -> 361 bytes 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 2da8aef..402d78e 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,8 @@ And here’s the same query using effdsl: import ( es "github.com/elastic/go-elasticsearch/v8" - "github.com/sdqri/effdsl" - mq "github.com/sdqri/effdsl/queries/matchquery" + "github.com/sdqri/effdsl/v2" + mq "github.com/sdqri/effdsl/v2/queries/matchquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/index.md b/docs-src/docs/index.md index b0297a1..2d66fbd 100644 --- a/docs-src/docs/index.md +++ b/docs-src/docs/index.md @@ -70,8 +70,8 @@ And here’s the same query using effdsl: import ( es "github.com/elastic/go-elasticsearch/v8" - "github.com/sdqri/effdsl" - mq "github.com/sdqri/effdsl/queries/matchquery" + "github.com/sdqri/effdsl/v2" + mq "github.com/sdqri/effdsl/v2/queries/matchquery" ) query, err := effdsl.Define( @@ -85,10 +85,10 @@ res, err := es.Search( ) ``` -For more examples and details on query parameters, visit the [documentation](https://sdqri.github.io/effdsl). +For more examples and details on query parameters, visit the documentation. ## 🀝 Contribution Contributions are welcome! Whether it's fixing a bug πŸ›, adding a new feature 🌟, or improving the documentation πŸ“š, your help is appreciated. Please check out the CONTRIBUTING.md guide to get started. ## πŸ“œ License -This project is licensed under the **MIT License**. For more details, see the [License](LICENSE.md) file. πŸ“„ ( **In short:** You can use, modify, and distribute this software freely as long as you include the original copyright notice and license. The software is provided "as-is" without warranties or guarantees.) +This project is licensed under the **MIT License**. For more details, see the [License](https://github.com/sdqri/effdsl/blob/master/LICENSE) file. πŸ“„ ( **In short:** You can use, modify, and distribute this software freely as long as you include the original copyright notice and license. The software is provided "as-is" without warranties or guarantees.) diff --git a/docs-src/docs/match_query.md b/docs-src/docs/match_query.md index 019eb3c..c93a565 100644 --- a/docs-src/docs/match_query.md +++ b/docs-src/docs/match_query.md @@ -8,8 +8,8 @@ A match query returns documents that match a provided text, number, date, or boo import ( es "github.com/elastic/go-elasticsearch/v8" - "github.com/sdqri/effdsl" - mq "github.com/sdqri/effdsl/queries/matchquery" + "github.com/sdqri/effdsl/v2" + mq "github.com/sdqri/effdsl/v2/queries/matchquery" ) query, err := effdsl.Define( diff --git a/docs/index.html b/docs/index.html index 727517e..8ddc37a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1196,8 +1196,8 @@

πŸ” Examples:

import (
     es "github.com/elastic/go-elasticsearch/v8"
 
-    "github.com/sdqri/effdsl"
-    mq "github.com/sdqri/effdsl/queries/matchquery"
+    "github.com/sdqri/effdsl/v2"
+    mq "github.com/sdqri/effdsl/v2/queries/matchquery"
 )
 
 query, err := effdsl.Define(
@@ -1210,11 +1210,11 @@ 

πŸ” Examples:

es.Search.WithBody(strings.NewReader(query)), )
-

For more examples and details on query parameters, visit the documentation.

+

For more examples and details on query parameters, visit the documentation.

🀝 Contribution

Contributions are welcome! Whether it's fixing a bug πŸ›, adding a new feature 🌟, or improving the documentation πŸ“š, your help is appreciated. Please check out the CONTRIBUTING.md guide to get started.

πŸ“œ License

-

This project is licensed under the MIT License. For more details, see the License file. πŸ“„ ( In short: You can use, modify, and distribute this software freely as long as you include the original copyright notice and license. The software is provided "as-is" without warranties or guarantees.)

+

This project is licensed under the MIT License. For more details, see the License file. πŸ“„ ( In short: You can use, modify, and distribute this software freely as long as you include the original copyright notice and license. The software is provided "as-is" without warranties or guarantees.)

diff --git a/docs/match_query/index.html b/docs/match_query/index.html index c657bb4..97adb1d 100644 --- a/docs/match_query/index.html +++ b/docs/match_query/index.html @@ -1228,8 +1228,8 @@

Example

import (
     es "github.com/elastic/go-elasticsearch/v8"
 
-    "github.com/sdqri/effdsl"
-    mq "github.com/sdqri/effdsl/queries/matchquery"
+    "github.com/sdqri/effdsl/v2"
+    mq "github.com/sdqri/effdsl/v2/queries/matchquery"
 )
 
 query, err := effdsl.Define(
diff --git a/docs/search/search_index.json b/docs/search/search_index.json
index 8508c4d..3882155 100644
--- a/docs/search/search_index.json
+++ b/docs/search/search_index.json
@@ -1 +1 @@
-{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Introduction","text":"

effdsl provides a simple and functional way to build Elasticsearch queries in Go.Instead of relying on maps or, even worse, raw string literals to describe queries\u2014which can be error-prone and lack features like easy parameterization, type safety, auto-completion, and compile-time validation\u2014 effdsl allows you to construct queries using intuitive function calls. This reduces the risk of subtle bugs caused by misspellings, makes parameterization easier and safer, and simplifies the process of constructing complex queries.

Moreover, its design makes the procedural creation of queries both straightforward and refined, making it particularly useful for cases where queries need to be generated programmatically. (This started because I needed to implement an interpreter of an internal DSL into Elasticsearch queries.) The module focuses solely on building the query body, without direct integration with the database, allowing seamless integration into an existing Go codebase.

effdsl supports most compound queries, full-text queries, and term-level queries. For a complete list of supported query types, please refer to the API coverage file in the effdsl GitHub repository. If there's a query type that isn't yet supported, feel free to open an issue or, even better, submit a pull request. \ud83d\ude4c

"},{"location":"#getting-started","title":"Getting started","text":""},{"location":"#getting-effdsl","title":"Getting effdsl","text":"

With Go module support, simply add the following import

import \"github.com/sdqri/effdsl\"\n

to your code, and then go [build|run|test] will automatically fetch the necessary dependencies.

Otherwise, run the following Go command to install the effdsl package:

$ go get -u github.com/sdqri/effdsl/v2\n
"},{"location":"#how-to-use","title":"How to use","text":"

Start with effdsl.Define(), and use types and documentations to find suitable options.

"},{"location":"#examples","title":"\ud83d\udd0d Examples:","text":"

Traditional Way:

Here\u2019s a simple match query in the traditional way using raw strings in Go:

import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n)\n\nquery := `{\n  \"query\": {\n    \"match\": {\n      \"message\": {\n        \"query\": \"Hello World\"\n      }\n    }\n  }\n}`\n\nres, err := es.Search(\n  es.Search.WithBody(strings.NewReader(query)),\n)\n

Using effdsl:

And here\u2019s the same query using effdsl:

import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl\"\n    mq \"github.com/sdqri/effdsl/queries/matchquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mq.MatchQuery(\"message\", \"Hello World\"),\n    ),\n)\n\nres, err := es.Search(\n  es.Search.WithBody(strings.NewReader(query)),\n)\n

For more examples and details on query parameters, visit the documentation.

"},{"location":"#contribution","title":"\ud83e\udd1d Contribution","text":"

Contributions are welcome! Whether it's fixing a bug \ud83d\udc1b, adding a new feature \ud83c\udf1f, or improving the documentation \ud83d\udcda, your help is appreciated. Please check out the CONTRIBUTING.md guide to get started.

"},{"location":"#license","title":"\ud83d\udcdc License","text":"

This project is licensed under the MIT License. For more details, see the License file. \ud83d\udcc4 ( In short: You can use, modify, and distribute this software freely as long as you include the original copyright notice and license. The software is provided \"as-is\" without warranties or guarantees.)

"},{"location":"api_coverage/","title":"API Coverage","text":""},{"location":"api_coverage/#compound-queries","title":"Compound queries","text":"
  • [x] bool query
  • [x] boosting query
  • [x] constant score query
  • [x] disjunction max query
  • [ ] function_score query
"},{"location":"api_coverage/#full-text-queries","title":"Full text queries","text":"
  • [ ] intervals query
  • [x] match query
  • [x] match_bool_prefix query
  • [x] match_phrase query
  • [x] match_phrase_prefix query
  • [ ] multi_match query
  • [ ] combined_fields query
  • [x] query_string query
  • [x] simple_query_string query
"},{"location":"api_coverage/#term-level-queries","title":"Term-level queries","text":"
  • [x] exists query
  • [x] fuzzy query
  • [x] ids query
  • [x] prefix query
  • [x] range query
  • [x] regexp query
  • [x] term query
  • [x] terms query
  • [x] terms_set query
  • [x] wildcard query
"},{"location":"api_coverage/#customize-search-results-options","title":"Customize Search results (options)","text":"
  • [x] Collapse search results
  • [ ] Filter search results
  • [ ] Highlighting
  • [ ] Long-running searches
  • [ ] Near real-time search
  • [x] Paginate search results (Supported methods: Simple paginating, Search after)
  • [ ] Retrieve inner hits
  • [x] Retrieve selected fields (Supported methods: Source filtering)
  • [ ] Search across clusters
  • [ ] Search multiple data streams and indices
  • [ ] Search shard routing
  • [ ] Search templates
  • [x] Sort search results (Suppoerted Parameters : value, order)
  • [ ] kNN search
"},{"location":"api_coverage/#search-apis","title":"Search APIs","text":"
  • [x] Point in time
"},{"location":"bool_query/","title":"Boolean Query","text":"

A query that matches documents based on boolean combinations of other queries. The bool query maps to Lucene BooleanQuery. It is constructed using one or more boolean clauses, each with a specific occurrence type. The occurrence types are:

"},{"location":"bool_query/#occur-types","title":"Occur Types","text":"
  • must The clause (query) must appear in matching documents and will contribute to the score.

  • filter The clause (query) must appear in matching documents. Unlike must, the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching.

  • should The clause (query) should appear in the matching document.

  • must_not The clause (query) must not appear in the matching documents. Clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned.

The bool query adopts a more-matches-is-better approach, so the score from each matching must or should clause will be added together to provide the final _score for each document.

"},{"location":"bool_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mq \"github.com/sdqri/effdsl/v2/queries/matchquery\"\n    bq \"github.com/sdqri/effdsl/v2/queries/boolquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        bq.BoolQuery(\n            bq.Must(mq.MatchQuery(effdsl.M{\"user.name\": \"john_doe\"})),\n            bq.Must(mq.MatchQuery(\"post.status\": \"published\")),\n            bq.Filter(mq.MatchQuery(\"category\": \"technology\")),\n            bq.Filter(mq.MatchQuery(\"tags\": \"go\")),\n            bq.Should(mq.MatchQuery(\"title\": \"elasticsearch\")),\n            bq.Should(mq.MatchQuery(\"content\": \"search optimization\")),\n            bq.MustNot(mq.MatchQuery(\"user.role\": \"banned\")),\n            bq.MustNot(mq.MatchQuery(\"status\": \"draft\")),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"bool_query/#parameters","title":"Parameters","text":"
  • Must(query) (Optional, Functional option) The clause must appear in matching documents and will contribute to the score.

  • Filter(query) (Optional, Functional option) The clause must appear in matching documents. Unlike must, the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching.

  • Should(query) (Optional, Functional option) The clause should appear in the matching document.

  • MustNot(query) (Optional, Functional option) The clause must not appear in the matching documents. Clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned.

  • WithMinimumShouldMatch(string) (Optional, Functional option) Minimum number of clauses that must match for a document to be returned.

"},{"location":"bool_query/#additional-information","title":"Additional Information","text":"

For more details on the boolean query and its parameters, refer to the official Elasticsearch documentation on bool queries.

"},{"location":"boosting_query/","title":"Boosting Query","text":"

A boosting query matches documents based on a positive query while reducing the relevance score of documents that also match a negative query. This type of query is useful for situations where you want to boost the relevance of documents that match a primary condition but penalize documents that match a secondary, less desired condition. The boosting query is constructed using a positive query, a negative query, and a negative boost factor.

"},{"location":"boosting_query/#example","title":"Example","text":"

import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    bq \"github.com/sdqri/effdsl/v2/queries/boostingquery\"\n    tq \"github.com/sdqri/effdsl/v2/queries/termquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        bq.BoostingQuery(\n            tq.TermQuery(\"text\", \"apple\"),\n            tq.TermQuery(\"text\", \"pie tart fruit crumble tree\"),\n            0.5, \n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
Positional requierd parameters

"},{"location":"boosting_query/#parameters","title":"Parameters","text":""},{"location":"boosting_query/#parameters_1","title":"Parameters","text":"
  • Positive (Query) (Required, positional) The query that documents must match to be considered for inclusion in the results.

  • Negative (Query) (Required, positional) The query object used to reduce the relevance score of documents matching this query.

  • NegativeBoost (float64) (Required, positional) A floating-point number between 0 and 1.0 used to decrease the relevance scores of documents matching the negative query.

"},{"location":"boosting_query/#additional-information","title":"Additional Information","text":"

For more details on the boosting query and its parameters, refer to the official Elasticsearch documentation on boosting queries.

"},{"location":"constant_score/","title":"Constant Score Query","text":"

A constant score query wraps a filter query and returns every matching document with a relevance score equal to the boost parameter value. This query type is useful when you want to apply a uniform score to all documents that match a specific filter query.

"},{"location":"constant_score/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    csq \"github.com/sdqri/effdsl/v2/queries/constantscore\"\n    tq \"github.com/sdqri/effdsl/v2/queries/termquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        csq.ConstantScoreQuery(\n            tq.TermQuery(\"user.id\", \"kimchy\"),\n            1.2\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"constant_score/#parameters","title":"Parameters","text":"
  • Filter (effdsl.Query) (Required, positional) The query object that documents must match. This is a required parameter.

  • Boost (float64) (Required, positional) A floating-point number used as the constant relevance score for every document matching the filter query. This is a required parameter and defaults to 1.0 if not specified.

"},{"location":"constant_score/#additional-information","title":"Additional Information","text":"

For more details on the constant score query and its parameters, refer to the official Elasticsearch documentation on constant score queries.

"},{"location":"dis_max_query/","title":"Disjunction Max Query","text":"

A disjunction max query (dis_max) is used to find documents that match multiple query clauses. The query returns documents that match any of the provided queries, and the relevance score is determined based on the best match. This query is useful for combining multiple queries into one and adjusting their scores with a tie-breaker.

"},{"location":"dis_max_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    dmq \"github.com/sdqri/effdsl/v2/queries/dismaxquery\"\n    tq \"github.com/sdqri/effdsl/v2/queries/termquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        dmq.DisMaxQuery(\n            []effdsl.QueryResult{\n                tq.TermQuery(\"title\", \"Quick pets\"),\n                tq.TermQuery(\"body\", \"Quick pets\"),\n            },\n            dmq.WithTieBreaker(0.7),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"dis_max_query/#parameters","title":"Parameters","text":"
  • Queries ([]query) (Required, positional) An array of query objects that documents must match. This is a required parameter.

  • WithTieBreaker (float64) (Optional, Functional option) A floating-point number used to adjust the relevance scores when multiple queries match. This is an optional parameter.

"},{"location":"dis_max_query/#additional-information","title":"Additional Information","text":"

For more details on the disjunction max query and its parameters, refer to the official Elasticsearch documentation on dis_max queries.

"},{"location":"exists_query/","title":"Exists Query","text":"

An exists query returns documents that contain an indexed value for a specified field. This query is useful for checking if a document contains a specific field.

"},{"location":"exists_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    eq \"github.com/sdqri/effdsl/v2/queries/existsquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        eq.ExistsQuery(\"field_name\"),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"exists_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.
"},{"location":"exists_query/#additional-information","title":"Additional Information","text":"

For more details on the exists query and its parameters, refer to the official Elasticsearch documentation on exists queries.

"},{"location":"fuzzy_query/","title":"Fuzzy Query","text":"

Returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance.

An edit distance is the number of one-character changes needed to turn one term into another. These changes can include:

  • Changing a character (e.g., box \u2192 fox)
  • Removing a character (e.g., black \u2192 lack)
  • Inserting a character (e.g., sic \u2192 sick)
  • Transposing two adjacent characters (e.g., act \u2192 cat)

To find similar terms, the fuzzy query creates a set of all possible variations, or expansions, of the search term within a specified edit distance. The query then returns exact matches for each expansion.

"},{"location":"fuzzy_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    eq \"github.com/sdqri/effdsl/v2/queries/existsquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        fq.FuzzyQuery(\n            \"user.id\",\n            \"ki\",\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"fuzzy_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Value (string) (Required, positional) The term you wish to find in the provided field. This is a required parameter.

  • WithFuzziness (string) (Optional, Functional option) The degree of fuzziness allowed for the search term (e.g., \"AUTO\", \"1\", \"2\", etc.). Defaults to no fuzziness.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to match. Defaults to 50.

  • WithPrefixLength (int) (Optional, Functional option) Number of initial characters that must match exactly. Defaults to 0.

  • WithTranspositions (bool) (Optional, Functional option) If true, allows transpositions of two adjacent characters. Defaults to true.

  • WithRewrite (Rewrite) (Optional, Functional option) Method used to rewrite the query. Valid values are:

    • constant_score: Query is rewritten to a constant score query.
    • scoring_boolean: Query is rewritten to a scoring boolean query.
    • constant_score_boolean: Query is rewritten to a constant score boolean query.
    • top_terms_N: Query is rewritten to match the top N scoring terms.
    • top_terms_boost_N: Query is rewritten to match the top N scoring terms with boosting.
    • top_terms_blended_freqs_N: Query is rewritten to match the top N scoring terms with blended frequencies.
"},{"location":"fuzzy_query/#additional-information","title":"Additional Information","text":"

For more details on the fuzzy query and its parameters, refer to the official Elasticsearch documentation on fuzzy queries.

"},{"location":"ids_query/","title":"IDs Query","text":"

Returns documents based on their IDs.

"},{"location":"ids_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    iq \"github.com/sdqri/effdsl/v2/queries/idsquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        iq.IDsQuery(\"1\", \"4\", \"100\"),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"ids_query/#parameters","title":"Parameters","text":"
  • Values (...string) (Required, positional) An array of document IDs. This is a required parameter.
"},{"location":"ids_query/#additional-information","title":"Additional Information","text":"

For more details on the IDs query, see the official Elasticsearch documentation on IDs queries.

"},{"location":"match_bool_prefix/","title":"Match Bool Prefix Query","text":"

A match bool prefix query analyzes its input and constructs a bool query from the terms. Each term except the last is used in a term query, and the last term is used in a prefix query.

"},{"location":"match_bool_prefix/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mbpq \"github.com/sdqri/effdsl/v2/queries/matchboolprefix\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mbpq.MatchBoolPrefixQuery(\n            \"message\",\n            \"quick brown f\",\n            mbpq.WithAnalyzer(\"keyword\"),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"match_bool_prefix/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Query (string) (Required, positional) The query text you wish to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. If no analyzer is provided, the default analyzer for the field is used.

"},{"location":"match_bool_prefix/#additional-information","title":"Additional Information","text":"

For more details on the match bool prefix query and its parameters, refer to the official Elasticsearch documentation on match bool prefix queries.

"},{"location":"match_phrase_prefix/","title":"Match Phrase Prefix Query","text":"

A match phrase prefix query returns documents that match a given phrase with a prefix, considering the position of the terms. The provided text is analyzed before matching.

"},{"location":"match_phrase_prefix/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"match_phrase_prefix/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"match_phrase_prefix/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

"},{"location":"match_phrase_query/","title":"Match Phrase Query","text":"

A match phrase query returns documents that match a given phrase, considering the position of the terms. The provided text is analyzed before matching.

"},{"location":"match_phrase_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"match_phrase_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"match_phrase_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nmpq \"github.com/sdqri/effdsl/v2/queries/matchphrasequery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( mpq.MatchPhraseQuery( \"field_name\", \"some phrase query\", mpq.WithAnalyzer(\"my_analyzer\"), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"match_phrase_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithZeroTermsquery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"match_phrase_query/#additional-information_1","title":"Additional Information","text":"

For more details on the match phrase query and its parameters, refer to the official Elasticsearch documentation on match phrase queries.

"},{"location":"match_query/","title":"Match Query","text":"

A match query returns documents that match a provided text, number, date, or boolean value. The provided text is analyzed before matching.

"},{"location":"match_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl\"\n    mq \"github.com/sdqri/effdsl/queries/matchquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mq.MatchQuery(\n            \"field_name\",\n            \"some match query\",\n            mq.WithOperator(mq.AND),\n            mq.WithFuzzinessParameter(mq.FuzzinessAUTO),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"match_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"match_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nmq \"github.com/sdqri/effdsl/v2/queries/matchquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( mq.MatchQuery( \"field_name\", \"some match query\", mq.WithOperator(mq.AND), mq.WithFuzzinessParameter(mq.FuzzinessAUTO), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"match_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Query (string) (Required, positional) The text, number, boolean value, or date you wish to find in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithAutoGenerateSynonymsPhrase (bool) (Optional, Functional option) If true, match phrase queries are automatically created for multi-term synonyms.

  • WithBoost (float64) (Optional, Functional option) Floating-point number used to decrease or increase the relevance scores of the query.

  • WithFuzzinessParameter (int) (Optional, Functional option) Maximum number of terms to which the query will expand.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the query will expand. Defaults to 50.

  • WithPrefixLength (int) (Optional, Functional option) Number of beginning characters left unchanged for fuzzy matching. Defaults to 0.

  • WithFuzzyTranspositions (bool) (Optional, Functional option) If true, edits for fuzzy matching include transpositions of two adjacent characters.

  • WithFuzzyRewrite (FuzzyRewrite) (Optional, Functional option) Method used to rewrite the query. See the rewrite parameter for valid values and more information.

  • WithOperator (Operator) (Optional, Functional option) Boolean logic used to interpret text in the query value. Valid values are:

    • OR (Default): For example, a query value of \"capital of Hungary\" is interpreted as \"capital OR of OR Hungary\".
    • AND: For example, a query value of \"capital of Hungary\" is interpreted as \"capital AND of AND Hungary\".
  • WithMinimumShouldMatch (string) (Optional, Functional option) Minimum number of clauses that must match for a document to be returned.

"},{"location":"match_query/#additional-information_1","title":"Additional Information","text":"

For more details on the match query and its parameters, refer to the official Elasticsearch documentation on match queries.

"},{"location":"prefix_query/","title":"Prefix Query","text":"

A prefix query returns documents that contain terms starting with the specified prefix in a given field.

"},{"location":"prefix_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"prefix_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"prefix_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\npq \"github.com/sdqri/effdsl/v2/queries/prefixquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( pq.PrefixQuery( \"name\", \"al\", ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"prefix_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Value (string) (Required, positional) The prefix you wish to match against terms in the provided field. This is a required parameter.

  • WithRewrite (Rewrite) (Optional, Functional option) The method used to rewrite the query. Valid values are:

    • constant_score: Query is rewritten to a constant score query.
    • scoring_boolean: Query is rewritten to a scoring boolean query.
    • constant_score_boolean: Query is rewritten to a constant score boolean query.
    • top_terms_N: Query is rewritten to match the top N scoring terms.
    • top_terms_boost_N: Query is rewritten to match the top N scoring terms with boosting.
    • top_terms_blended_freqs_N: Query is rewritten to match the top N scoring terms with blended frequencies.
  • WithCaseInsensitive (bool) (Optional, Functional option) Whether the query is case insensitive. Defaults to false.

"},{"location":"prefix_query/#additional-information_1","title":"Additional Information","text":"

For more details on the prefix query and its parameters, refer to the official Elasticsearch documentation on prefix queries.

"},{"location":"query_string/","title":"Query String Query","text":"

A query string query parses and executes a search query based on a query string syntax. It allows for flexible and complex query expressions.

"},{"location":"query_string/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"query_string/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"query_string/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nqs \"github.com/sdqri/effdsl/v2/queries/querystring\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( qs.QueryString( \"alice\", qs.WithFields(\"first_name\", \"last_name\") qs.WithBoost(1.5), qs.WithFuzziness(\"AUTO\"), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"query_string/#parameters_1","title":"Parameters","text":"
  • Query (string) (Required, positional) The query string to parse and use for search. This is a required parameter.

  • WithDefaultField (string) (Optional, Functional option) Default field to search if no field is provided in the query string.

  • WithAllowLeadingWildcard () (Optional, Functional option) If true, wildcard characters * and ? are allowed as the first character in the query string. Defaults to true.

  • WithAnalyzeWildcard () (Optional, Functional option) If true, the query attempts to analyze wildcard terms in the query string. Defaults to false.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query string into tokens.

  • WithAutoGenerateSynonymsPhrase (bool) (Optional, Functional option) If true, match phrase queries are automatically created for multi-term synonyms. Defaults to true.

  • WithBoost (float64) (Optional, Functional option) Floating point number used to adjust the relevance scores of the query.

  • WithDefaultOperator (Operator) (Optional, Functional option) Default boolean logic used to interpret text in the query string. Valid values are:

    • OR: Logical OR.
    • AND: Logical AND.
  • WithEnablePositionIncrements (bool) (Optional, Functional option) If true, enable position increments in queries constructed from the query string search.

  • WithFields (...string) (Optional, Functional option) Array of fields to search. Supports wildcards *.

  • WithFuzziness (string) (Optional, Functional option) Maximum edit distance allowed for fuzzy matching.

  • WithFuzzyMaxExpansions (int) (Optional, Functional option) Maximum number of terms for fuzzy matching expansion.

  • WithFuzzyPrefixLength (int) (Optional, Functional option) Number of beginning characters left unchanged for fuzzy matching.

  • WithFuzzyTranspositions (bool) (Optional, Functional option) If true, edits for fuzzy matching include transpositions of adjacent characters.

  • WithLenient (bool) (Optional, Functional option) If true, format-based errors are ignored.

  • WithMaxDeterminizedStates (int) (Optional, Functional option) Maximum number of automaton states required for the query.

  • WithMinimumShouldMatch (string) (Optional, Functional option) Minimum number of clauses that must match for a document to be returned.

  • WithQuoteAnalyzer (string) (Optional, Functional option) Analyzer used to convert quoted text in the query string into tokens.

  • WithPhraseSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases.

  • WithQuoteFieldSuffix (string) (Optional, Functional option) Suffix appended to quoted text in the query string.

  • WithRewrite (Rewrite) (Optional, Functional option) Method used to rewrite the query. Valid values are:

    • constant_score
    • scoring_boolean
    • constant_score_boolean
    • top_terms_N
    • top_terms_boost_N
    • top_terms_blended_freqs_N
  • WithTimeZone (string) (Optional, Functional option) UTC offset or IANA time zone used to convert date values in the query string to UTC.

"},{"location":"query_string/#additional-information_1","title":"Additional Information","text":"

For more details on the query string query and its parameters, refer to the official Elasticsearch documentation on query string queries.

"},{"location":"range_query/","title":"Range Query","text":"

A range query returns documents that contain terms within a specified range. It supports querying for values that are greater than, less than, or between certain values.

"},{"location":"range_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"range_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"range_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nrq \"github.com/sdqri/effdsl/v2/queries/rangequery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( rq.RangeQuery( \"age\", rq.WithGT(10), rq.WithLTE(20), rq.WithBoost(2.0), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"range_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • WithGT (any) (Optional, Functional option) Greater than. If specified, the range query will include terms greater than this value.

  • WithGTE (any) (Optional, Functional option) Greater than or equal to. If specified, the range query will include terms greater than or equal to this value.

  • WithLT (any) (Optional, Functional option) Less than. If specified, the range query will include terms less than this value.

  • WithLTE (any) (Optional, Functional option) Less than or equal to. If specified, the range query will include terms less than or equal to this value.

  • WithFormat (string) (Optional, Functional option) Date format used to convert date values in the query.

  • WithRelation (Relation) (Optional, Functional option) Indicates how the range query matches values for range fields. Valid values are:

    • INTERSECTS
    • CONTAINS
    • WITHIN
  • WithTimeZone (string) (Optional, Functional option) Coordinated Universal Time (UTC) offset or IANA time zone used to convert date values in the query to UTC.

  • WithBoost (float64) (Optional, Functional option) Floating point number used to decrease or increase the relevance scores of the query. Defaults to 1.0.

"},{"location":"range_query/#additional-information_1","title":"Additional Information","text":"

For more details on the range query and its parameters, refer to the official Elasticsearch documentation on range queries.

"},{"location":"regexp_query/","title":"Regexp Query","text":"

A regexp query returns documents that contain terms matching a specified regular expression. The regular expression can include additional options for controlling the match behavior.

"},{"location":"regexp_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"regexp_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"regexp_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nrq \"github.com/sdqri/effdsl/v2/queries/regexpquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( rq.RegexpQuery( \"user.id\", \"k.*y\", rq.WithFlags(\"ALL\"), rq.WithCaseInsensitive(), rq.WithMaxDeterminizedStates(10000), rq.WithRQRewrite(rq.ConstantScore), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"regexp_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Value (string) (Required, positional) The regular expression pattern to match against the field. This is a required parameter.

  • WithFlags (string) (Optional, Functional option) Additional matching options for the regular expression.

  • WithCaseInsensitive (bool) (Optional, Functional option) If true, the regular expression is case-insensitive.

  • WithMaxDeterminizedStates (int) (Optional, Functional option) The maximum number of automaton states required for the query. Lower values will reduce memory usage but increase query time.

  • WithRewrite (Rewrite) (Optional, Functional option) The method used to rewrite the query. Valid values are:

    • constant_score: Query is rewritten to a constant score query.
    • scoring_boolean: Query is rewritten to a scoring boolean query.
    • constant_score_boolean: Query is rewritten to a constant score boolean query.
    • top_terms_N: Query is rewritten to match the top N scoring terms.
    • top_terms_boost_N: Query is rewritten to match the top N scoring terms with boosting.
    • top_terms_blended_freqs_N: Query is rewritten to match the top N scoring terms with blended frequencies.
"},{"location":"regexp_query/#additional-information_1","title":"Additional Information","text":"

For more details on the regexp query and its parameters, refer to the official Elasticsearch documentation on regexp queries.

"},{"location":"release_notes/","title":"Release Notes","text":""},{"location":"release_notes/#v212-latest","title":"v2.1.2 Latest","text":""},{"location":"release_notes/#whats-new","title":"What's New","text":"
  • \u2728 Add support for boosting query, constant score query, disjunction max query in compound queries.
  • \u2728 Add support for match query, match_bool_prefix query, match_phrase query, match_phrase_prefix query, simple_query_string query in full text queries.
  • \u2728 Add support for ids query, prefix query, wildcard query in term-level queries.
  • \ud83d\udcdd Add documentation for all supported queries.
"},{"location":"release_notes/#whats-changed","title":"What's Changed","text":"
  • \ud83d\udd04 Separate queries into packages to remove prefixed parameters.
  • \u2705 Complete functional options in queries.
"},{"location":"release_notes/#v120","title":"v1.2.0","text":"
  • \ud83d\udca1 Extend MatchQuery parameters & add WildcardQuery and Suggesters. PR #2 by @moguchev.
"},{"location":"simple_query_string/","title":"Simple Query String","text":"

A simple query string query parses a provided query string and searches for documents using the specified fields and options. It supports a variety of query options to refine the search.

"},{"location":"simple_query_string/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"simple_query_string/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"simple_query_string/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nsqs \"github.com/sdqri/effdsl/v2/queries/simplequerystring\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( sqs.SimpleQueryString( \"fried eggs\" +(eggplant | potato) -frittata, sqs.WithFields(\"title^5\", \"body\"), sqs.WithDefaultOperator(sqs.AND), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"simple_query_string/#parameters_1","title":"Parameters","text":"
  • Query (string) (Required, positional) The query string you wish to parse and use for search. This is a required parameter.

  • WithFields (...string) (Optional, Functional option) Array of fields to search. Supports wildcards *.

  • WithDefaultOperator (Operator) (Optional, Functional option) Default boolean logic used to interpret text in the query string. Valid values are:

    • OR: For example, a query value of \"capital of Hungary\" is interpreted as \"capital OR of OR Hungary\".
    • AND: For example, a query value of \"capital of Hungary\" is interpreted as \"capital AND of AND Hungary\".
  • WithAnalyzeWildcard () (Optional, Functional option) If true, the query attempts to analyze wildcard terms in the query string. Defaults to false.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert text in the query string into tokens.

  • WithAutoGenerateSynonymsPhrase (bool) (Optional, Functional option) If true, match phrase queries are automatically created for multi-term synonyms. Defaults to true.

  • WithFlags (string) (Optional, Functional option) List of enabled operators for the simple query string syntax. Defaults to ALL (all operators). See Limit operators for valid values.

  • WithFuzzyMaxExpansions (int) (Optional, Functional option) Maximum number of terms for fuzzy matching expansion.

  • WithFuzzyPrefixLength (int) (Optional, Functional option) Number of beginning characters left unchanged for fuzzy matching.

  • WithFuzzyTranspositions (bool) (Optional, Functional option) If true, edits for fuzzy matching include transpositions of adjacent characters.

  • WithLenient (bool) (Optional, Functional option) If true, format-based errors are ignored.

  • WithMinimumShouldMatch (string) (Optional, Functional option) Minimum number of clauses that must match for a document to be returned.

  • WithQuoteFieldSuffix (string) (Optional, Functional option) Suffix appended to quoted text in the query string.

"},{"location":"simple_query_string/#additional-information_1","title":"Additional Information","text":"

For more details on the simple query string query and its parameters, refer to the official Elasticsearch documentation on simple query string queries.

"},{"location":"term_query/","title":"Term Query","text":"

A term query returns documents that contain an exact term in a provided field. The term must exactly match the field value, including whitespace and capitalization.

"},{"location":"term_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"term_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"term_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\ntq \"github.com/sdqri/effdsl/v2/queries/termquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( tq.TermQuery( \"user.id\", \"kimchy\", tq.WithBoost(1.5), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"term_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Value (string) (Required, positional) The term you wish to find in the provided field. This is a required parameter. The term must exactly match the field value, including whitespace and capitalization.

  • WithBoost (float64) (Optional, Functional option) Floating point number used to decrease or increase the relevance scores of the query. Defaults to 1.0.

  • WithCaseInsensitive (bool) (Optional, Functional option) Allows ASCII case-insensitive matching of the value with the indexed field values when set to true. Defaults to false.

"},{"location":"term_query/#additional-information_1","title":"Additional Information","text":"

For more details on the term query and its parameters, refer to the official Elasticsearch documentation on term queries.

"},{"location":"terms_query/","title":"Terms Query","text":"

A terms query returns documents that contain one or more exact terms in a provided field.

"},{"location":"terms_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"terms_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"terms_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\ntsq \"github.com/sdqri/effdsl/v2/queries/termsquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( tsq.TermsQuery( \"user.id\", []string{\"kimchy\", \"elkbee\"}, tsq.WithBoost(1.0), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"terms_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Values ([]string) (Required, positional) The array of terms you wish to find in the provided field. This is a required parameter.

  • WithBoost (float64) (Optional, Functional option) Floating point number used to decrease or increase the relevance scores of a query. Defaults to 1.0.

"},{"location":"terms_query/#additional-information_1","title":"Additional Information","text":"

For more details on the terms query and its parameters, refer to the official Elasticsearch documentation on terms queries.

"},{"location":"terms_set_query/","title":"Terms Set Query","text":"

A term set query returns documents that contain at least one of the specified terms in a provided field. To return a document, at least one of the terms must exactly match the field value, including whitespace and capitalization.

"},{"location":"terms_set_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"terms_set_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"terms_set_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\ntsq \"github.com/sdqri/effdsl/v2/queries/termssetquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( tsq.TermsSetQuery( \"programming_languages\", []string{\"c++\", \"java\", \"php\"}, tsq.WithMinimumShouldMatchField(\"required_matches\"), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"terms_set_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Terms ([]string) (Required, positional) An array of terms you wish to find in the provided field. To return a document, at least one of the terms must exactly match the field value, including whitespace and capitalization. This is a required parameter.

  • WithMinimumShouldMatchField (string) (Optional, Functional option) The field that holds the minimum number of terms that should match. Only used when minimum_should_match_script is not set.

  • WithMinimumShouldMatchScript (string) (Optional, Functional option) Script that returns the minimum number of terms that should match.

"},{"location":"terms_set_query/#additional-information_1","title":"Additional Information","text":"

For more details on the term set query and its parameters, refer to the official Elasticsearch documentation on term set queries.

"},{"location":"wildcard_query/","title":"Wildcard Query","text":"

A wildcard query returns documents that contain terms matching a wildcard pattern.

"},{"location":"wildcard_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"wildcard_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"wildcard_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nwq \"github.com/sdqri/effdsl/v2/queries/wildcardquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( wq.WildcardQuery( \"user.id\", \"ki*y\", wq.WithBoost(1.0), wq.WithRewrite(wcq.ConstantScoreBlended), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"wildcard_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Value (string) (Required, positional) The wildcard pattern for terms you wish to find in the provided field. This is a required parameter.

  • WithBoost (float64) (Optional, Functional option) Floating point number used to decrease or increase the relevance scores of a query. Defaults to 1.0.

  • WithCaseInsensitive (bool) (Optional, Functional option) If true, the wildcard pattern is treated as case-insensitive.

  • WithRewrite (Rewrite) (Optional, Functional option) Method used to rewrite the query. For valid values and more information, see the rewrite parameter.

"},{"location":"wildcard_query/#additional-information_1","title":"Additional Information","text":"

For more details on the wildcard query and its parameters, refer to the official Elasticsearch documentation on wildcard queries.

"}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Introduction","text":"

effdsl provides a simple and functional way to build Elasticsearch queries in Go.Instead of relying on maps or, even worse, raw string literals to describe queries\u2014which can be error-prone and lack features like easy parameterization, type safety, auto-completion, and compile-time validation\u2014 effdsl allows you to construct queries using intuitive function calls. This reduces the risk of subtle bugs caused by misspellings, makes parameterization easier and safer, and simplifies the process of constructing complex queries.

Moreover, its design makes the procedural creation of queries both straightforward and refined, making it particularly useful for cases where queries need to be generated programmatically. (This started because I needed to implement an interpreter of an internal DSL into Elasticsearch queries.) The module focuses solely on building the query body, without direct integration with the database, allowing seamless integration into an existing Go codebase.

effdsl supports most compound queries, full-text queries, and term-level queries. For a complete list of supported query types, please refer to the API coverage file in the effdsl GitHub repository. If there's a query type that isn't yet supported, feel free to open an issue or, even better, submit a pull request. \ud83d\ude4c

"},{"location":"#getting-started","title":"Getting started","text":""},{"location":"#getting-effdsl","title":"Getting effdsl","text":"

With Go module support, simply add the following import

import \"github.com/sdqri/effdsl\"\n

to your code, and then go [build|run|test] will automatically fetch the necessary dependencies.

Otherwise, run the following Go command to install the effdsl package:

$ go get -u github.com/sdqri/effdsl/v2\n
"},{"location":"#how-to-use","title":"How to use","text":"

Start with effdsl.Define(), and use types and documentations to find suitable options.

"},{"location":"#examples","title":"\ud83d\udd0d Examples:","text":"

Traditional Way:

Here\u2019s a simple match query in the traditional way using raw strings in Go:

import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n)\n\nquery := `{\n  \"query\": {\n    \"match\": {\n      \"message\": {\n        \"query\": \"Hello World\"\n      }\n    }\n  }\n}`\n\nres, err := es.Search(\n  es.Search.WithBody(strings.NewReader(query)),\n)\n

Using effdsl:

And here\u2019s the same query using effdsl:

import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mq \"github.com/sdqri/effdsl/v2/queries/matchquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mq.MatchQuery(\"message\", \"Hello World\"),\n    ),\n)\n\nres, err := es.Search(\n  es.Search.WithBody(strings.NewReader(query)),\n)\n

For more examples and details on query parameters, visit the documentation.

"},{"location":"#contribution","title":"\ud83e\udd1d Contribution","text":"

Contributions are welcome! Whether it's fixing a bug \ud83d\udc1b, adding a new feature \ud83c\udf1f, or improving the documentation \ud83d\udcda, your help is appreciated. Please check out the CONTRIBUTING.md guide to get started.

"},{"location":"#license","title":"\ud83d\udcdc License","text":"

This project is licensed under the MIT License. For more details, see the License file. \ud83d\udcc4 ( In short: You can use, modify, and distribute this software freely as long as you include the original copyright notice and license. The software is provided \"as-is\" without warranties or guarantees.)

"},{"location":"api_coverage/","title":"API Coverage","text":""},{"location":"api_coverage/#compound-queries","title":"Compound queries","text":"
  • [x] bool query
  • [x] boosting query
  • [x] constant score query
  • [x] disjunction max query
  • [ ] function_score query
"},{"location":"api_coverage/#full-text-queries","title":"Full text queries","text":"
  • [ ] intervals query
  • [x] match query
  • [x] match_bool_prefix query
  • [x] match_phrase query
  • [x] match_phrase_prefix query
  • [ ] multi_match query
  • [ ] combined_fields query
  • [x] query_string query
  • [x] simple_query_string query
"},{"location":"api_coverage/#term-level-queries","title":"Term-level queries","text":"
  • [x] exists query
  • [x] fuzzy query
  • [x] ids query
  • [x] prefix query
  • [x] range query
  • [x] regexp query
  • [x] term query
  • [x] terms query
  • [x] terms_set query
  • [x] wildcard query
"},{"location":"api_coverage/#customize-search-results-options","title":"Customize Search results (options)","text":"
  • [x] Collapse search results
  • [ ] Filter search results
  • [ ] Highlighting
  • [ ] Long-running searches
  • [ ] Near real-time search
  • [x] Paginate search results (Supported methods: Simple paginating, Search after)
  • [ ] Retrieve inner hits
  • [x] Retrieve selected fields (Supported methods: Source filtering)
  • [ ] Search across clusters
  • [ ] Search multiple data streams and indices
  • [ ] Search shard routing
  • [ ] Search templates
  • [x] Sort search results (Suppoerted Parameters : value, order)
  • [ ] kNN search
"},{"location":"api_coverage/#search-apis","title":"Search APIs","text":"
  • [x] Point in time
"},{"location":"bool_query/","title":"Boolean Query","text":"

A query that matches documents based on boolean combinations of other queries. The bool query maps to Lucene BooleanQuery. It is constructed using one or more boolean clauses, each with a specific occurrence type. The occurrence types are:

"},{"location":"bool_query/#occur-types","title":"Occur Types","text":"
  • must The clause (query) must appear in matching documents and will contribute to the score.

  • filter The clause (query) must appear in matching documents. Unlike must, the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching.

  • should The clause (query) should appear in the matching document.

  • must_not The clause (query) must not appear in the matching documents. Clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned.

The bool query adopts a more-matches-is-better approach, so the score from each matching must or should clause will be added together to provide the final _score for each document.

"},{"location":"bool_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mq \"github.com/sdqri/effdsl/v2/queries/matchquery\"\n    bq \"github.com/sdqri/effdsl/v2/queries/boolquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        bq.BoolQuery(\n            bq.Must(mq.MatchQuery(effdsl.M{\"user.name\": \"john_doe\"})),\n            bq.Must(mq.MatchQuery(\"post.status\": \"published\")),\n            bq.Filter(mq.MatchQuery(\"category\": \"technology\")),\n            bq.Filter(mq.MatchQuery(\"tags\": \"go\")),\n            bq.Should(mq.MatchQuery(\"title\": \"elasticsearch\")),\n            bq.Should(mq.MatchQuery(\"content\": \"search optimization\")),\n            bq.MustNot(mq.MatchQuery(\"user.role\": \"banned\")),\n            bq.MustNot(mq.MatchQuery(\"status\": \"draft\")),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"bool_query/#parameters","title":"Parameters","text":"
  • Must(query) (Optional, Functional option) The clause must appear in matching documents and will contribute to the score.

  • Filter(query) (Optional, Functional option) The clause must appear in matching documents. Unlike must, the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching.

  • Should(query) (Optional, Functional option) The clause should appear in the matching document.

  • MustNot(query) (Optional, Functional option) The clause must not appear in the matching documents. Clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned.

  • WithMinimumShouldMatch(string) (Optional, Functional option) Minimum number of clauses that must match for a document to be returned.

"},{"location":"bool_query/#additional-information","title":"Additional Information","text":"

For more details on the boolean query and its parameters, refer to the official Elasticsearch documentation on bool queries.

"},{"location":"boosting_query/","title":"Boosting Query","text":"

A boosting query matches documents based on a positive query while reducing the relevance score of documents that also match a negative query. This type of query is useful for situations where you want to boost the relevance of documents that match a primary condition but penalize documents that match a secondary, less desired condition. The boosting query is constructed using a positive query, a negative query, and a negative boost factor.

"},{"location":"boosting_query/#example","title":"Example","text":"

import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    bq \"github.com/sdqri/effdsl/v2/queries/boostingquery\"\n    tq \"github.com/sdqri/effdsl/v2/queries/termquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        bq.BoostingQuery(\n            tq.TermQuery(\"text\", \"apple\"),\n            tq.TermQuery(\"text\", \"pie tart fruit crumble tree\"),\n            0.5, \n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
Positional requierd parameters

"},{"location":"boosting_query/#parameters","title":"Parameters","text":""},{"location":"boosting_query/#parameters_1","title":"Parameters","text":"
  • Positive (Query) (Required, positional) The query that documents must match to be considered for inclusion in the results.

  • Negative (Query) (Required, positional) The query object used to reduce the relevance score of documents matching this query.

  • NegativeBoost (float64) (Required, positional) A floating-point number between 0 and 1.0 used to decrease the relevance scores of documents matching the negative query.

"},{"location":"boosting_query/#additional-information","title":"Additional Information","text":"

For more details on the boosting query and its parameters, refer to the official Elasticsearch documentation on boosting queries.

"},{"location":"constant_score/","title":"Constant Score Query","text":"

A constant score query wraps a filter query and returns every matching document with a relevance score equal to the boost parameter value. This query type is useful when you want to apply a uniform score to all documents that match a specific filter query.

"},{"location":"constant_score/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    csq \"github.com/sdqri/effdsl/v2/queries/constantscore\"\n    tq \"github.com/sdqri/effdsl/v2/queries/termquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        csq.ConstantScoreQuery(\n            tq.TermQuery(\"user.id\", \"kimchy\"),\n            1.2\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"constant_score/#parameters","title":"Parameters","text":"
  • Filter (effdsl.Query) (Required, positional) The query object that documents must match. This is a required parameter.

  • Boost (float64) (Required, positional) A floating-point number used as the constant relevance score for every document matching the filter query. This is a required parameter and defaults to 1.0 if not specified.

"},{"location":"constant_score/#additional-information","title":"Additional Information","text":"

For more details on the constant score query and its parameters, refer to the official Elasticsearch documentation on constant score queries.

"},{"location":"dis_max_query/","title":"Disjunction Max Query","text":"

A disjunction max query (dis_max) is used to find documents that match multiple query clauses. The query returns documents that match any of the provided queries, and the relevance score is determined based on the best match. This query is useful for combining multiple queries into one and adjusting their scores with a tie-breaker.

"},{"location":"dis_max_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    dmq \"github.com/sdqri/effdsl/v2/queries/dismaxquery\"\n    tq \"github.com/sdqri/effdsl/v2/queries/termquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        dmq.DisMaxQuery(\n            []effdsl.QueryResult{\n                tq.TermQuery(\"title\", \"Quick pets\"),\n                tq.TermQuery(\"body\", \"Quick pets\"),\n            },\n            dmq.WithTieBreaker(0.7),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"dis_max_query/#parameters","title":"Parameters","text":"
  • Queries ([]query) (Required, positional) An array of query objects that documents must match. This is a required parameter.

  • WithTieBreaker (float64) (Optional, Functional option) A floating-point number used to adjust the relevance scores when multiple queries match. This is an optional parameter.

"},{"location":"dis_max_query/#additional-information","title":"Additional Information","text":"

For more details on the disjunction max query and its parameters, refer to the official Elasticsearch documentation on dis_max queries.

"},{"location":"exists_query/","title":"Exists Query","text":"

An exists query returns documents that contain an indexed value for a specified field. This query is useful for checking if a document contains a specific field.

"},{"location":"exists_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    eq \"github.com/sdqri/effdsl/v2/queries/existsquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        eq.ExistsQuery(\"field_name\"),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"exists_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.
"},{"location":"exists_query/#additional-information","title":"Additional Information","text":"

For more details on the exists query and its parameters, refer to the official Elasticsearch documentation on exists queries.

"},{"location":"fuzzy_query/","title":"Fuzzy Query","text":"

Returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance.

An edit distance is the number of one-character changes needed to turn one term into another. These changes can include:

  • Changing a character (e.g., box \u2192 fox)
  • Removing a character (e.g., black \u2192 lack)
  • Inserting a character (e.g., sic \u2192 sick)
  • Transposing two adjacent characters (e.g., act \u2192 cat)

To find similar terms, the fuzzy query creates a set of all possible variations, or expansions, of the search term within a specified edit distance. The query then returns exact matches for each expansion.

"},{"location":"fuzzy_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    eq \"github.com/sdqri/effdsl/v2/queries/existsquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        fq.FuzzyQuery(\n            \"user.id\",\n            \"ki\",\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"fuzzy_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Value (string) (Required, positional) The term you wish to find in the provided field. This is a required parameter.

  • WithFuzziness (string) (Optional, Functional option) The degree of fuzziness allowed for the search term (e.g., \"AUTO\", \"1\", \"2\", etc.). Defaults to no fuzziness.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to match. Defaults to 50.

  • WithPrefixLength (int) (Optional, Functional option) Number of initial characters that must match exactly. Defaults to 0.

  • WithTranspositions (bool) (Optional, Functional option) If true, allows transpositions of two adjacent characters. Defaults to true.

  • WithRewrite (Rewrite) (Optional, Functional option) Method used to rewrite the query. Valid values are:

    • constant_score: Query is rewritten to a constant score query.
    • scoring_boolean: Query is rewritten to a scoring boolean query.
    • constant_score_boolean: Query is rewritten to a constant score boolean query.
    • top_terms_N: Query is rewritten to match the top N scoring terms.
    • top_terms_boost_N: Query is rewritten to match the top N scoring terms with boosting.
    • top_terms_blended_freqs_N: Query is rewritten to match the top N scoring terms with blended frequencies.
"},{"location":"fuzzy_query/#additional-information","title":"Additional Information","text":"

For more details on the fuzzy query and its parameters, refer to the official Elasticsearch documentation on fuzzy queries.

"},{"location":"ids_query/","title":"IDs Query","text":"

Returns documents based on their IDs.

"},{"location":"ids_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    iq \"github.com/sdqri/effdsl/v2/queries/idsquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        iq.IDsQuery(\"1\", \"4\", \"100\"),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"ids_query/#parameters","title":"Parameters","text":"
  • Values (...string) (Required, positional) An array of document IDs. This is a required parameter.
"},{"location":"ids_query/#additional-information","title":"Additional Information","text":"

For more details on the IDs query, see the official Elasticsearch documentation on IDs queries.

"},{"location":"match_bool_prefix/","title":"Match Bool Prefix Query","text":"

A match bool prefix query analyzes its input and constructs a bool query from the terms. Each term except the last is used in a term query, and the last term is used in a prefix query.

"},{"location":"match_bool_prefix/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mbpq \"github.com/sdqri/effdsl/v2/queries/matchboolprefix\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mbpq.MatchBoolPrefixQuery(\n            \"message\",\n            \"quick brown f\",\n            mbpq.WithAnalyzer(\"keyword\"),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"match_bool_prefix/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Query (string) (Required, positional) The query text you wish to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. If no analyzer is provided, the default analyzer for the field is used.

"},{"location":"match_bool_prefix/#additional-information","title":"Additional Information","text":"

For more details on the match bool prefix query and its parameters, refer to the official Elasticsearch documentation on match bool prefix queries.

"},{"location":"match_phrase_prefix/","title":"Match Phrase Prefix Query","text":"

A match phrase prefix query returns documents that match a given phrase with a prefix, considering the position of the terms. The provided text is analyzed before matching.

"},{"location":"match_phrase_prefix/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"match_phrase_prefix/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"match_phrase_prefix/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

"},{"location":"match_phrase_query/","title":"Match Phrase Query","text":"

A match phrase query returns documents that match a given phrase, considering the position of the terms. The provided text is analyzed before matching.

"},{"location":"match_phrase_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"match_phrase_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"match_phrase_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nmpq \"github.com/sdqri/effdsl/v2/queries/matchphrasequery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( mpq.MatchPhraseQuery( \"field_name\", \"some phrase query\", mpq.WithAnalyzer(\"my_analyzer\"), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"match_phrase_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithZeroTermsquery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"match_phrase_query/#additional-information_1","title":"Additional Information","text":"

For more details on the match phrase query and its parameters, refer to the official Elasticsearch documentation on match phrase queries.

"},{"location":"match_query/","title":"Match Query","text":"

A match query returns documents that match a provided text, number, date, or boolean value. The provided text is analyzed before matching.

"},{"location":"match_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mq \"github.com/sdqri/effdsl/v2/queries/matchquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mq.MatchQuery(\n            \"field_name\",\n            \"some match query\",\n            mq.WithOperator(mq.AND),\n            mq.WithFuzzinessParameter(mq.FuzzinessAUTO),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"match_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"match_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nmq \"github.com/sdqri/effdsl/v2/queries/matchquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( mq.MatchQuery( \"field_name\", \"some match query\", mq.WithOperator(mq.AND), mq.WithFuzzinessParameter(mq.FuzzinessAUTO), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"match_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Query (string) (Required, positional) The text, number, boolean value, or date you wish to find in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithAutoGenerateSynonymsPhrase (bool) (Optional, Functional option) If true, match phrase queries are automatically created for multi-term synonyms.

  • WithBoost (float64) (Optional, Functional option) Floating-point number used to decrease or increase the relevance scores of the query.

  • WithFuzzinessParameter (int) (Optional, Functional option) Maximum number of terms to which the query will expand.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the query will expand. Defaults to 50.

  • WithPrefixLength (int) (Optional, Functional option) Number of beginning characters left unchanged for fuzzy matching. Defaults to 0.

  • WithFuzzyTranspositions (bool) (Optional, Functional option) If true, edits for fuzzy matching include transpositions of two adjacent characters.

  • WithFuzzyRewrite (FuzzyRewrite) (Optional, Functional option) Method used to rewrite the query. See the rewrite parameter for valid values and more information.

  • WithOperator (Operator) (Optional, Functional option) Boolean logic used to interpret text in the query value. Valid values are:

    • OR (Default): For example, a query value of \"capital of Hungary\" is interpreted as \"capital OR of OR Hungary\".
    • AND: For example, a query value of \"capital of Hungary\" is interpreted as \"capital AND of AND Hungary\".
  • WithMinimumShouldMatch (string) (Optional, Functional option) Minimum number of clauses that must match for a document to be returned.

"},{"location":"match_query/#additional-information_1","title":"Additional Information","text":"

For more details on the match query and its parameters, refer to the official Elasticsearch documentation on match queries.

"},{"location":"prefix_query/","title":"Prefix Query","text":"

A prefix query returns documents that contain terms starting with the specified prefix in a given field.

"},{"location":"prefix_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"prefix_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"prefix_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\npq \"github.com/sdqri/effdsl/v2/queries/prefixquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( pq.PrefixQuery( \"name\", \"al\", ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"prefix_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Value (string) (Required, positional) The prefix you wish to match against terms in the provided field. This is a required parameter.

  • WithRewrite (Rewrite) (Optional, Functional option) The method used to rewrite the query. Valid values are:

    • constant_score: Query is rewritten to a constant score query.
    • scoring_boolean: Query is rewritten to a scoring boolean query.
    • constant_score_boolean: Query is rewritten to a constant score boolean query.
    • top_terms_N: Query is rewritten to match the top N scoring terms.
    • top_terms_boost_N: Query is rewritten to match the top N scoring terms with boosting.
    • top_terms_blended_freqs_N: Query is rewritten to match the top N scoring terms with blended frequencies.
  • WithCaseInsensitive (bool) (Optional, Functional option) Whether the query is case insensitive. Defaults to false.

"},{"location":"prefix_query/#additional-information_1","title":"Additional Information","text":"

For more details on the prefix query and its parameters, refer to the official Elasticsearch documentation on prefix queries.

"},{"location":"query_string/","title":"Query String Query","text":"

A query string query parses and executes a search query based on a query string syntax. It allows for flexible and complex query expressions.

"},{"location":"query_string/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"query_string/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"query_string/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nqs \"github.com/sdqri/effdsl/v2/queries/querystring\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( qs.QueryString( \"alice\", qs.WithFields(\"first_name\", \"last_name\") qs.WithBoost(1.5), qs.WithFuzziness(\"AUTO\"), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"query_string/#parameters_1","title":"Parameters","text":"
  • Query (string) (Required, positional) The query string to parse and use for search. This is a required parameter.

  • WithDefaultField (string) (Optional, Functional option) Default field to search if no field is provided in the query string.

  • WithAllowLeadingWildcard () (Optional, Functional option) If true, wildcard characters * and ? are allowed as the first character in the query string. Defaults to true.

  • WithAnalyzeWildcard () (Optional, Functional option) If true, the query attempts to analyze wildcard terms in the query string. Defaults to false.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query string into tokens.

  • WithAutoGenerateSynonymsPhrase (bool) (Optional, Functional option) If true, match phrase queries are automatically created for multi-term synonyms. Defaults to true.

  • WithBoost (float64) (Optional, Functional option) Floating point number used to adjust the relevance scores of the query.

  • WithDefaultOperator (Operator) (Optional, Functional option) Default boolean logic used to interpret text in the query string. Valid values are:

    • OR: Logical OR.
    • AND: Logical AND.
  • WithEnablePositionIncrements (bool) (Optional, Functional option) If true, enable position increments in queries constructed from the query string search.

  • WithFields (...string) (Optional, Functional option) Array of fields to search. Supports wildcards *.

  • WithFuzziness (string) (Optional, Functional option) Maximum edit distance allowed for fuzzy matching.

  • WithFuzzyMaxExpansions (int) (Optional, Functional option) Maximum number of terms for fuzzy matching expansion.

  • WithFuzzyPrefixLength (int) (Optional, Functional option) Number of beginning characters left unchanged for fuzzy matching.

  • WithFuzzyTranspositions (bool) (Optional, Functional option) If true, edits for fuzzy matching include transpositions of adjacent characters.

  • WithLenient (bool) (Optional, Functional option) If true, format-based errors are ignored.

  • WithMaxDeterminizedStates (int) (Optional, Functional option) Maximum number of automaton states required for the query.

  • WithMinimumShouldMatch (string) (Optional, Functional option) Minimum number of clauses that must match for a document to be returned.

  • WithQuoteAnalyzer (string) (Optional, Functional option) Analyzer used to convert quoted text in the query string into tokens.

  • WithPhraseSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases.

  • WithQuoteFieldSuffix (string) (Optional, Functional option) Suffix appended to quoted text in the query string.

  • WithRewrite (Rewrite) (Optional, Functional option) Method used to rewrite the query. Valid values are:

    • constant_score
    • scoring_boolean
    • constant_score_boolean
    • top_terms_N
    • top_terms_boost_N
    • top_terms_blended_freqs_N
  • WithTimeZone (string) (Optional, Functional option) UTC offset or IANA time zone used to convert date values in the query string to UTC.

"},{"location":"query_string/#additional-information_1","title":"Additional Information","text":"

For more details on the query string query and its parameters, refer to the official Elasticsearch documentation on query string queries.

"},{"location":"range_query/","title":"Range Query","text":"

A range query returns documents that contain terms within a specified range. It supports querying for values that are greater than, less than, or between certain values.

"},{"location":"range_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"range_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"range_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nrq \"github.com/sdqri/effdsl/v2/queries/rangequery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( rq.RangeQuery( \"age\", rq.WithGT(10), rq.WithLTE(20), rq.WithBoost(2.0), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"range_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • WithGT (any) (Optional, Functional option) Greater than. If specified, the range query will include terms greater than this value.

  • WithGTE (any) (Optional, Functional option) Greater than or equal to. If specified, the range query will include terms greater than or equal to this value.

  • WithLT (any) (Optional, Functional option) Less than. If specified, the range query will include terms less than this value.

  • WithLTE (any) (Optional, Functional option) Less than or equal to. If specified, the range query will include terms less than or equal to this value.

  • WithFormat (string) (Optional, Functional option) Date format used to convert date values in the query.

  • WithRelation (Relation) (Optional, Functional option) Indicates how the range query matches values for range fields. Valid values are:

    • INTERSECTS
    • CONTAINS
    • WITHIN
  • WithTimeZone (string) (Optional, Functional option) Coordinated Universal Time (UTC) offset or IANA time zone used to convert date values in the query to UTC.

  • WithBoost (float64) (Optional, Functional option) Floating point number used to decrease or increase the relevance scores of the query. Defaults to 1.0.

"},{"location":"range_query/#additional-information_1","title":"Additional Information","text":"

For more details on the range query and its parameters, refer to the official Elasticsearch documentation on range queries.

"},{"location":"regexp_query/","title":"Regexp Query","text":"

A regexp query returns documents that contain terms matching a specified regular expression. The regular expression can include additional options for controlling the match behavior.

"},{"location":"regexp_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"regexp_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"regexp_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nrq \"github.com/sdqri/effdsl/v2/queries/regexpquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( rq.RegexpQuery( \"user.id\", \"k.*y\", rq.WithFlags(\"ALL\"), rq.WithCaseInsensitive(), rq.WithMaxDeterminizedStates(10000), rq.WithRQRewrite(rq.ConstantScore), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"regexp_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Value (string) (Required, positional) The regular expression pattern to match against the field. This is a required parameter.

  • WithFlags (string) (Optional, Functional option) Additional matching options for the regular expression.

  • WithCaseInsensitive (bool) (Optional, Functional option) If true, the regular expression is case-insensitive.

  • WithMaxDeterminizedStates (int) (Optional, Functional option) The maximum number of automaton states required for the query. Lower values will reduce memory usage but increase query time.

  • WithRewrite (Rewrite) (Optional, Functional option) The method used to rewrite the query. Valid values are:

    • constant_score: Query is rewritten to a constant score query.
    • scoring_boolean: Query is rewritten to a scoring boolean query.
    • constant_score_boolean: Query is rewritten to a constant score boolean query.
    • top_terms_N: Query is rewritten to match the top N scoring terms.
    • top_terms_boost_N: Query is rewritten to match the top N scoring terms with boosting.
    • top_terms_blended_freqs_N: Query is rewritten to match the top N scoring terms with blended frequencies.
"},{"location":"regexp_query/#additional-information_1","title":"Additional Information","text":"

For more details on the regexp query and its parameters, refer to the official Elasticsearch documentation on regexp queries.

"},{"location":"release_notes/","title":"Release Notes","text":""},{"location":"release_notes/#v212-latest","title":"v2.1.2 Latest","text":""},{"location":"release_notes/#whats-new","title":"What's New","text":"
  • \u2728 Add support for boosting query, constant score query, disjunction max query in compound queries.
  • \u2728 Add support for match query, match_bool_prefix query, match_phrase query, match_phrase_prefix query, simple_query_string query in full text queries.
  • \u2728 Add support for ids query, prefix query, wildcard query in term-level queries.
  • \ud83d\udcdd Add documentation for all supported queries.
"},{"location":"release_notes/#whats-changed","title":"What's Changed","text":"
  • \ud83d\udd04 Separate queries into packages to remove prefixed parameters.
  • \u2705 Complete functional options in queries.
"},{"location":"release_notes/#v120","title":"v1.2.0","text":"
  • \ud83d\udca1 Extend MatchQuery parameters & add WildcardQuery and Suggesters. PR #2 by @moguchev.
"},{"location":"simple_query_string/","title":"Simple Query String","text":"

A simple query string query parses a provided query string and searches for documents using the specified fields and options. It supports a variety of query options to refine the search.

"},{"location":"simple_query_string/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"simple_query_string/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"simple_query_string/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nsqs \"github.com/sdqri/effdsl/v2/queries/simplequerystring\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( sqs.SimpleQueryString( \"fried eggs\" +(eggplant | potato) -frittata, sqs.WithFields(\"title^5\", \"body\"), sqs.WithDefaultOperator(sqs.AND), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"simple_query_string/#parameters_1","title":"Parameters","text":"
  • Query (string) (Required, positional) The query string you wish to parse and use for search. This is a required parameter.

  • WithFields (...string) (Optional, Functional option) Array of fields to search. Supports wildcards *.

  • WithDefaultOperator (Operator) (Optional, Functional option) Default boolean logic used to interpret text in the query string. Valid values are:

    • OR: For example, a query value of \"capital of Hungary\" is interpreted as \"capital OR of OR Hungary\".
    • AND: For example, a query value of \"capital of Hungary\" is interpreted as \"capital AND of AND Hungary\".
  • WithAnalyzeWildcard () (Optional, Functional option) If true, the query attempts to analyze wildcard terms in the query string. Defaults to false.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert text in the query string into tokens.

  • WithAutoGenerateSynonymsPhrase (bool) (Optional, Functional option) If true, match phrase queries are automatically created for multi-term synonyms. Defaults to true.

  • WithFlags (string) (Optional, Functional option) List of enabled operators for the simple query string syntax. Defaults to ALL (all operators). See Limit operators for valid values.

  • WithFuzzyMaxExpansions (int) (Optional, Functional option) Maximum number of terms for fuzzy matching expansion.

  • WithFuzzyPrefixLength (int) (Optional, Functional option) Number of beginning characters left unchanged for fuzzy matching.

  • WithFuzzyTranspositions (bool) (Optional, Functional option) If true, edits for fuzzy matching include transpositions of adjacent characters.

  • WithLenient (bool) (Optional, Functional option) If true, format-based errors are ignored.

  • WithMinimumShouldMatch (string) (Optional, Functional option) Minimum number of clauses that must match for a document to be returned.

  • WithQuoteFieldSuffix (string) (Optional, Functional option) Suffix appended to quoted text in the query string.

"},{"location":"simple_query_string/#additional-information_1","title":"Additional Information","text":"

For more details on the simple query string query and its parameters, refer to the official Elasticsearch documentation on simple query string queries.

"},{"location":"term_query/","title":"Term Query","text":"

A term query returns documents that contain an exact term in a provided field. The term must exactly match the field value, including whitespace and capitalization.

"},{"location":"term_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"term_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"term_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\ntq \"github.com/sdqri/effdsl/v2/queries/termquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( tq.TermQuery( \"user.id\", \"kimchy\", tq.WithBoost(1.5), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"term_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Value (string) (Required, positional) The term you wish to find in the provided field. This is a required parameter. The term must exactly match the field value, including whitespace and capitalization.

  • WithBoost (float64) (Optional, Functional option) Floating point number used to decrease or increase the relevance scores of the query. Defaults to 1.0.

  • WithCaseInsensitive (bool) (Optional, Functional option) Allows ASCII case-insensitive matching of the value with the indexed field values when set to true. Defaults to false.

"},{"location":"term_query/#additional-information_1","title":"Additional Information","text":"

For more details on the term query and its parameters, refer to the official Elasticsearch documentation on term queries.

"},{"location":"terms_query/","title":"Terms Query","text":"

A terms query returns documents that contain one or more exact terms in a provided field.

"},{"location":"terms_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"terms_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"terms_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\ntsq \"github.com/sdqri/effdsl/v2/queries/termsquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( tsq.TermsQuery( \"user.id\", []string{\"kimchy\", \"elkbee\"}, tsq.WithBoost(1.0), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"terms_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Values ([]string) (Required, positional) The array of terms you wish to find in the provided field. This is a required parameter.

  • WithBoost (float64) (Optional, Functional option) Floating point number used to decrease or increase the relevance scores of a query. Defaults to 1.0.

"},{"location":"terms_query/#additional-information_1","title":"Additional Information","text":"

For more details on the terms query and its parameters, refer to the official Elasticsearch documentation on terms queries.

"},{"location":"terms_set_query/","title":"Terms Set Query","text":"

A term set query returns documents that contain at least one of the specified terms in a provided field. To return a document, at least one of the terms must exactly match the field value, including whitespace and capitalization.

"},{"location":"terms_set_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"terms_set_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"terms_set_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\ntsq \"github.com/sdqri/effdsl/v2/queries/termssetquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( tsq.TermsSetQuery( \"programming_languages\", []string{\"c++\", \"java\", \"php\"}, tsq.WithMinimumShouldMatchField(\"required_matches\"), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"terms_set_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Terms ([]string) (Required, positional) An array of terms you wish to find in the provided field. To return a document, at least one of the terms must exactly match the field value, including whitespace and capitalization. This is a required parameter.

  • WithMinimumShouldMatchField (string) (Optional, Functional option) The field that holds the minimum number of terms that should match. Only used when minimum_should_match_script is not set.

  • WithMinimumShouldMatchScript (string) (Optional, Functional option) Script that returns the minimum number of terms that should match.

"},{"location":"terms_set_query/#additional-information_1","title":"Additional Information","text":"

For more details on the term set query and its parameters, refer to the official Elasticsearch documentation on term set queries.

"},{"location":"wildcard_query/","title":"Wildcard Query","text":"

A wildcard query returns documents that contain terms matching a wildcard pattern.

"},{"location":"wildcard_query/#example","title":"Example","text":"
import (\n    es \"github.com/elastic/go-elasticsearch/v8\"\n\n    \"github.com/sdqri/effdsl/v2\"\n    mppq \"github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery\"\n)\n\nquery, err := effdsl.Define(\n    effdsl.WithQuery(\n        mppq.MatchPhrasePrefixQuery(\n            \"field_name\",\n            \"some phrase prefix query\",\n            mppq.WithAnalyzer(\"my_analyzer\"),\n            mppq.WithSlop(2),\n            mppq.WithMaxExpansions(10),\n        ),\n    ),\n)\n\nres, err := es.Search(\n    es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"wildcard_query/#parameters","title":"Parameters","text":"
  • Field (string) (Required, positional) The field to search. This is a required parameter.

  • Query (string) (Required, positional) The text to search for in the provided field. This is a required parameter.

  • WithAnalyzer (string) (Optional, Functional option) Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the field. If no analyzer is mapped, the index\u2019s default analyzer is used.

  • WithSlop (int) (Optional, Functional option) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0.

  • WithMaxExpansions (int) (Optional, Functional option) Maximum number of terms to which the last provided term will expand. Defaults to not expanding terms.

  • WithZeroTermsQuery (ZeroTerms) (Optional, Functional option) Indicates what to do when the analyzed text contains no terms. Valid values are:

    • none (Default): No documents are returned if the analyzer removes all tokens.
    • all: Returns all documents, similar to a match_all query.
"},{"location":"wildcard_query/#additional-information","title":"Additional Information","text":"

For more details on the match phrase prefix query and its parameters, refer to the official Elasticsearch documentation on match phrase prefix queries.

\"github.com/sdqri/effdsl/v2\"\nwq \"github.com/sdqri/effdsl/v2/queries/wildcardquery\"\n

)

query, err := effdsl.Define( effdsl.WithQuery( wq.WildcardQuery( \"user.id\", \"ki*y\", wq.WithBoost(1.0), wq.WithRewrite(wcq.ConstantScoreBlended), ), ), )

res, err := es.Search( es.Search.WithBody(strings.NewReader(query)), ) ```

"},{"location":"wildcard_query/#parameters_1","title":"Parameters","text":"
  • Field (string) (Required, positional) The field you wish to search. This is a required parameter.

  • Value (string) (Required, positional) The wildcard pattern for terms you wish to find in the provided field. This is a required parameter.

  • WithBoost (float64) (Optional, Functional option) Floating point number used to decrease or increase the relevance scores of a query. Defaults to 1.0.

  • WithCaseInsensitive (bool) (Optional, Functional option) If true, the wildcard pattern is treated as case-insensitive.

  • WithRewrite (Rewrite) (Optional, Functional option) Method used to rewrite the query. For valid values and more information, see the rewrite parameter.

"},{"location":"wildcard_query/#additional-information_1","title":"Additional Information","text":"

For more details on the wildcard query and its parameters, refer to the official Elasticsearch documentation on wildcard queries.

"}]} \ No newline at end of file diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 7e5842c..d6e7b4e 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -2,117 +2,117 @@ https://sdqri.org/effdsl/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/api_coverage/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/bool_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/boosting_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/constant_score/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/dis_max_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/exists_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/fuzzy_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/ids_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/match_bool_prefix/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/match_phrase_prefix/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/match_phrase_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/match_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/prefix_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/query_string/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/range_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/regexp_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/release_notes/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/simple_query_string/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/term_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/terms_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/terms_set_query/ - 2024-08-21 + 2024-08-22 daily https://sdqri.org/effdsl/wildcard_query/ - 2024-08-21 + 2024-08-22 daily \ No newline at end of file diff --git a/docs/sitemap.xml.gz b/docs/sitemap.xml.gz index e1fefa9c3a583d923a7e7908e650ad6855270eb4..69d5fa587d0bd5170c09260e8e3c462c176f4dc7 100644 GIT binary patch literal 361 zcmV-v0hazBiwFovPR3>e|8r?{Wo=<_E_iKh0M*yMZi6ro0N_1Of!Kp7>X251Y<+@u zMy`E;CI7&kQ%Ih^hD24?F4ffwV9uvccLqd#TAaQcR?qwLu&=5Va-Vw$Q-kz9bO=+UrLmVYnTksM8{LMoH&fg$fR1lvw$zza_t#k8H+0#)!7rH?JCfE?Sa4Yf`#YzqjBp-60b z-T8XGu+TbPd%iCNnMNFSMhCE!;uq_@! z56j4yXJLJCeTYB|ePrBd@7?9Q1tXwi+u{{R%ysDxjID4sRx646uYlVj6{PtF^y^Lq H!VUlc)a$Y# literal 361 zcmV-v0hazBiwFqF{KRGg|8r?{Wo=<_E_iKh0M*yMZi6ro0N}k(f!Kpd)FG`1+4=w0ZS0Scps>md8GExguIzpNc$|1h=zwG&ZPq z$wD~|=@XiDJ@maMD;lxfevFosT+r>V-aT*X{bsk#A@{k5Ff~d)K#y>0wKVq9h=-XQ zL;N^?C6du}D&#WB0T}W=L$KZH40z#*qm;K3Tc8S_lJuz~6_8_lwV}?*nQZ}KHk61h zuRmX}7q&X1`Bu)!q{eQ2yF`TE%xsNuL`m>Zl)T%`Rd?$xTi)vGC}IB8G34QrhHdc> z2ACsbo`vPX^&tT<^pSDV-n+|p3noCvw#5sMnCtQ%7+c|FtX2~BUjf%cE=c