diff --git a/docs-src/docs/bool_query.md b/docs-src/docs/bool_query.md index 35c2fc0..6c3e9a2 100644 --- a/docs-src/docs/bool_query.md +++ b/docs-src/docs/bool_query.md @@ -23,10 +23,9 @@ The bool query adopts a more-matches-is-better approach, so the score from each ```go import ( es "github.com/elastic/go-elasticsearch/v8" - "github.com/sdqri/effdsl/v2" - mq "github.com/sdqri/effdsl/v2/queries/matchquery" - bq "github.com/sdqri/effdsl/v2/queries/boolquery" + mq "github.com/sdqri/effdsl/queries/matchquery" + bq "github.com/sdqri/effdsl/queries/boolquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/boosting_query.md b/docs-src/docs/boosting_query.md index ce52e8e..cf4fb91 100644 --- a/docs-src/docs/boosting_query.md +++ b/docs-src/docs/boosting_query.md @@ -7,10 +7,9 @@ A boosting query matches documents based on a positive query while reducing the ```go import ( es "github.com/elastic/go-elasticsearch/v8" - "github.com/sdqri/effdsl/v2" - bq "github.com/sdqri/effdsl/v2/queries/boostingquery" - tq "github.com/sdqri/effdsl/v2/queries/termquery" + bq "github.com/sdqri/effdsl/queries/boostingquery" + tq "github.com/sdqri/effdsl/queries/termquery" ) query, err := effdsl.Define( @@ -18,9 +17,8 @@ query, err := effdsl.Define( bq.BoostingQuery( tq.TermQuery("text", "apple"), tq.TermQuery("text", "pie tart fruit crumble tree"), - 0.5, - ), - ), + 0.5), + ), ) res, err := es.Search( diff --git a/docs-src/docs/constant_score.md b/docs-src/docs/constant_score.md index 3ed115a..960a885 100644 --- a/docs-src/docs/constant_score.md +++ b/docs-src/docs/constant_score.md @@ -7,18 +7,16 @@ A constant score query wraps a filter query and returns every matching document ```go import ( es "github.com/elastic/go-elasticsearch/v8" - "github.com/sdqri/effdsl/v2" - csq "github.com/sdqri/effdsl/v2/queries/constantscore" - tq "github.com/sdqri/effdsl/v2/queries/termquery" + csq "github.com/sdqri/effdsl/queries/constantscore" + tq "github.com/sdqri/effdsl/queries/termquery" ) query, err := effdsl.Define( effdsl.WithQuery( csq.ConstantScoreQuery( tq.TermQuery("user.id", "kimchy"), - 1.2 - ), + 1.2), ), ) diff --git a/docs-src/docs/dis_max_query.md b/docs-src/docs/dis_max_query.md index 8ecd4d2..e5c8ae0 100644 --- a/docs-src/docs/dis_max_query.md +++ b/docs-src/docs/dis_max_query.md @@ -7,10 +7,9 @@ A disjunction max query (dis_max) is used to find documents that match multiple ```go import ( es "github.com/elastic/go-elasticsearch/v8" - "github.com/sdqri/effdsl/v2" - dmq "github.com/sdqri/effdsl/v2/queries/dismaxquery" - tq "github.com/sdqri/effdsl/v2/queries/termquery" + dmq "github.com/sdqri/effdsl/queries/dismaxquery" + tq "github.com/sdqri/effdsl/queries/termquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/exists_query.md b/docs-src/docs/exists_query.md index 11b11c6..ca0d037 100644 --- a/docs-src/docs/exists_query.md +++ b/docs-src/docs/exists_query.md @@ -7,9 +7,8 @@ An exists query returns documents that contain an indexed value for a specified ```go import ( es "github.com/elastic/go-elasticsearch/v8" - "github.com/sdqri/effdsl/v2" - eq "github.com/sdqri/effdsl/v2/queries/existsquery" + eq "github.com/sdqri/effdsl/queries/existsquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/fuzzy_query.md b/docs-src/docs/fuzzy_query.md index 7a5456a..caef4b4 100644 --- a/docs-src/docs/fuzzy_query.md +++ b/docs-src/docs/fuzzy_query.md @@ -15,10 +15,9 @@ To find similar terms, the fuzzy query creates a set of all possible variations, ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - eq "github.com/sdqri/effdsl/v2/queries/existsquery" + eq "github.com/sdqri/effdsl/queries/existsquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/ids_query.md b/docs-src/docs/ids_query.md index cd9f0df..ab85185 100644 --- a/docs-src/docs/ids_query.md +++ b/docs-src/docs/ids_query.md @@ -6,10 +6,9 @@ Returns documents based on their IDs. ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - iq "github.com/sdqri/effdsl/v2/queries/idsquery" + iq "github.com/sdqri/effdsl/queries/idsquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/index.md b/docs-src/docs/index.md index 2d66fbd..9e62873 100644 --- a/docs-src/docs/index.md +++ b/docs-src/docs/index.md @@ -29,7 +29,7 @@ to your code, and then `go [build|run|test]` will automatically fetch the necess Otherwise, run the following Go command to install the `effdsl` package: ```sh -$ go get -u github.com/sdqri/effdsl/v2 +$ go get -u github.com/sdqri/effdsl ``` ### How to use @@ -76,8 +76,8 @@ import ( query, err := effdsl.Define( effdsl.WithQuery( - mq.MatchQuery("message", "Hello World"), - ), + mq.MatchQuery("message", "Hello World") + ), ) res, err := es.Search( diff --git a/docs-src/docs/match_bool_prefix.md b/docs-src/docs/match_bool_prefix.md index 193a937..deb1329 100644 --- a/docs-src/docs/match_bool_prefix.md +++ b/docs-src/docs/match_bool_prefix.md @@ -6,10 +6,9 @@ A match bool prefix query analyzes its input and constructs a bool query from th ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - mbpq "github.com/sdqri/effdsl/v2/queries/matchboolprefix" + mbpq "github.com/sdqri/effdsl/queries/matchboolprefix" ) query, err := effdsl.Define( diff --git a/docs-src/docs/match_phrase_prefix.md b/docs-src/docs/match_phrase_prefix.md index 35e6c55..c0bd5bb 100644 --- a/docs-src/docs/match_phrase_prefix.md +++ b/docs-src/docs/match_phrase_prefix.md @@ -6,10 +6,9 @@ A match phrase prefix query returns documents that match a given phrase with a p ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" + mppq "github.com/sdqri/effdsl/queries/matchphraseprefixquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/match_phrase_query.md b/docs-src/docs/match_phrase_query.md index 271709e..79f9fa0 100644 --- a/docs-src/docs/match_phrase_query.md +++ b/docs-src/docs/match_phrase_query.md @@ -6,57 +6,9 @@ A match phrase query returns documents that match a given phrase, considering th ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" -) - -query, err := effdsl.Define( - effdsl.WithQuery( - mppq.MatchPhrasePrefixQuery( - "field_name", - "some phrase prefix query", - mppq.WithAnalyzer("my_analyzer"), - mppq.WithSlop(2), - mppq.WithMaxExpansions(10), - ), - ), -) - -res, err := es.Search( - es.Search.WithBody(strings.NewReader(query)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - mpq "github.com/sdqri/effdsl/v2/queries/matchphrasequery" + mpq "github.com/sdqri/effdsl/queries/matchphrasequery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/match_query.md b/docs-src/docs/match_query.md index c93a565..b97a4b1 100644 --- a/docs-src/docs/match_query.md +++ b/docs-src/docs/match_query.md @@ -6,56 +6,9 @@ A match query returns documents that match a provided text, number, date, or boo ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mq "github.com/sdqri/effdsl/v2/queries/matchquery" -) - -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)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - mq "github.com/sdqri/effdsl/v2/queries/matchquery" + mq "github.com/sdqri/effdsl/queries/matchquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/prefix_query.md b/docs-src/docs/prefix_query.md index d8a2b6a..64113df 100644 --- a/docs-src/docs/prefix_query.md +++ b/docs-src/docs/prefix_query.md @@ -6,57 +6,9 @@ A prefix query returns documents that contain terms starting with the specified ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" -) - -query, err := effdsl.Define( - effdsl.WithQuery( - mppq.MatchPhrasePrefixQuery( - "field_name", - "some phrase prefix query", - mppq.WithAnalyzer("my_analyzer"), - mppq.WithSlop(2), - mppq.WithMaxExpansions(10), - ), - ), -) - -res, err := es.Search( - es.Search.WithBody(strings.NewReader(query)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - pq "github.com/sdqri/effdsl/v2/queries/prefixquery" + pq "github.com/sdqri/effdsl/queries/prefixquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/query_string.md b/docs-src/docs/query_string.md index c579979..ad2c392 100644 --- a/docs-src/docs/query_string.md +++ b/docs-src/docs/query_string.md @@ -6,57 +6,9 @@ A query string query parses and executes a search query based on a query string ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" -) - -query, err := effdsl.Define( - effdsl.WithQuery( - mppq.MatchPhrasePrefixQuery( - "field_name", - "some phrase prefix query", - mppq.WithAnalyzer("my_analyzer"), - mppq.WithSlop(2), - mppq.WithMaxExpansions(10), - ), - ), -) - -res, err := es.Search( - es.Search.WithBody(strings.NewReader(query)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - qs "github.com/sdqri/effdsl/v2/queries/querystring" + qs "github.com/sdqri/effdsl/queries/querystring" ) query, err := effdsl.Define( diff --git a/docs-src/docs/range_query.md b/docs-src/docs/range_query.md index 7b139cc..a05bcab 100644 --- a/docs-src/docs/range_query.md +++ b/docs-src/docs/range_query.md @@ -6,57 +6,9 @@ A range query returns documents that contain terms within a specified range. It ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" -) - -query, err := effdsl.Define( - effdsl.WithQuery( - mppq.MatchPhrasePrefixQuery( - "field_name", - "some phrase prefix query", - mppq.WithAnalyzer("my_analyzer"), - mppq.WithSlop(2), - mppq.WithMaxExpansions(10), - ), - ), -) - -res, err := es.Search( - es.Search.WithBody(strings.NewReader(query)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - rq "github.com/sdqri/effdsl/v2/queries/rangequery" + rq "github.com/sdqri/effdsl/queries/rangequery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/regexp_query.md b/docs-src/docs/regexp_query.md index 6748850..ac9657d 100644 --- a/docs-src/docs/regexp_query.md +++ b/docs-src/docs/regexp_query.md @@ -6,57 +6,9 @@ A regexp query returns documents that contain terms matching a specified regular ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" -) - -query, err := effdsl.Define( - effdsl.WithQuery( - mppq.MatchPhrasePrefixQuery( - "field_name", - "some phrase prefix query", - mppq.WithAnalyzer("my_analyzer"), - mppq.WithSlop(2), - mppq.WithMaxExpansions(10), - ), - ), -) - -res, err := es.Search( - es.Search.WithBody(strings.NewReader(query)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - rq "github.com/sdqri/effdsl/v2/queries/regexpquery" + rq "github.com/sdqri/effdsl/queries/regexpquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/simple_query_string.md b/docs-src/docs/simple_query_string.md index ab8d9dc..f4c0f37 100644 --- a/docs-src/docs/simple_query_string.md +++ b/docs-src/docs/simple_query_string.md @@ -6,57 +6,9 @@ A simple query string query parses a provided query string and searches for docu ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" -) - -query, err := effdsl.Define( - effdsl.WithQuery( - mppq.MatchPhrasePrefixQuery( - "field_name", - "some phrase prefix query", - mppq.WithAnalyzer("my_analyzer"), - mppq.WithSlop(2), - mppq.WithMaxExpansions(10), - ), - ), -) - -res, err := es.Search( - es.Search.WithBody(strings.NewReader(query)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - sqs "github.com/sdqri/effdsl/v2/queries/simplequerystring" + sqs "github.com/sdqri/effdsl/queries/simplequerystring" ) query, err := effdsl.Define( diff --git a/docs-src/docs/term_query.md b/docs-src/docs/term_query.md index e066c06..38114ee 100644 --- a/docs-src/docs/term_query.md +++ b/docs-src/docs/term_query.md @@ -6,57 +6,9 @@ A term query returns documents that contain an exact term in a provided field. T ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" -) - -query, err := effdsl.Define( - effdsl.WithQuery( - mppq.MatchPhrasePrefixQuery( - "field_name", - "some phrase prefix query", - mppq.WithAnalyzer("my_analyzer"), - mppq.WithSlop(2), - mppq.WithMaxExpansions(10), - ), - ), -) - -res, err := es.Search( - es.Search.WithBody(strings.NewReader(query)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - tq "github.com/sdqri/effdsl/v2/queries/termquery" + tq "github.com/sdqri/effdsl/queries/termquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/terms_query.md b/docs-src/docs/terms_query.md index 79617a9..b48b064 100644 --- a/docs-src/docs/terms_query.md +++ b/docs-src/docs/terms_query.md @@ -6,57 +6,9 @@ A terms query returns documents that contain one or more exact terms in a provid ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" -) - -query, err := effdsl.Define( - effdsl.WithQuery( - mppq.MatchPhrasePrefixQuery( - "field_name", - "some phrase prefix query", - mppq.WithAnalyzer("my_analyzer"), - mppq.WithSlop(2), - mppq.WithMaxExpansions(10), - ), - ), -) - -res, err := es.Search( - es.Search.WithBody(strings.NewReader(query)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - tsq "github.com/sdqri/effdsl/v2/queries/termsquery" + tsq "github.com/sdqri/effdsl/queries/termsquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/terms_set_query.md b/docs-src/docs/terms_set_query.md index 8ab8512..626943f 100644 --- a/docs-src/docs/terms_set_query.md +++ b/docs-src/docs/terms_set_query.md @@ -6,57 +6,9 @@ A term set query returns documents that contain at least one of the specified te ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" -) - -query, err := effdsl.Define( - effdsl.WithQuery( - mppq.MatchPhrasePrefixQuery( - "field_name", - "some phrase prefix query", - mppq.WithAnalyzer("my_analyzer"), - mppq.WithSlop(2), - mppq.WithMaxExpansions(10), - ), - ), -) - -res, err := es.Search( - es.Search.WithBody(strings.NewReader(query)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - tsq "github.com/sdqri/effdsl/v2/queries/termssetquery" + tsq "github.com/sdqri/effdsl/queries/termssetquery" ) query, err := effdsl.Define( diff --git a/docs-src/docs/wildcard_query.md b/docs-src/docs/wildcard_query.md index 6710976..3c96ff5 100644 --- a/docs-src/docs/wildcard_query.md +++ b/docs-src/docs/wildcard_query.md @@ -6,57 +6,9 @@ A wildcard query returns documents that contain terms matching a wildcard patter ```go import ( - es "github.com/elastic/go-elasticsearch/v8" - - "github.com/sdqri/effdsl/v2" - mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery" -) - -query, err := effdsl.Define( - effdsl.WithQuery( - mppq.MatchPhrasePrefixQuery( - "field_name", - "some phrase prefix query", - mppq.WithAnalyzer("my_analyzer"), - mppq.WithSlop(2), - mppq.WithMaxExpansions(10), - ), - ), -) - -res, err := es.Search( - es.Search.WithBody(strings.NewReader(query)), -) -``` -### Parameters - -* **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’s 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. - -### Additional Information - -For more details on the match phrase prefix query and its parameters, refer to the [official Elasticsearch documentation on match phrase prefix queries](https://elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html). - + es "github.com/elastic/go-elasticsearch/v8" "github.com/sdqri/effdsl/v2" - wq "github.com/sdqri/effdsl/v2/queries/wildcardquery" + wq "github.com/sdqri/effdsl/queries/wildcardquery" ) query, err := effdsl.Define( diff --git a/docs/bool_query/index.html b/docs/bool_query/index.html index 55be822..c02e176 100644 --- a/docs/bool_query/index.html +++ b/docs/bool_query/index.html @@ -1229,30 +1229,29 @@
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mq "github.com/sdqri/effdsl/v2/queries/matchquery"
- bq "github.com/sdqri/effdsl/v2/queries/boolquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- bq.BoolQuery(
- bq.Must(mq.MatchQuery(effdsl.M{"user.name": "john_doe"})),
- bq.Must(mq.MatchQuery("post.status": "published")),
- bq.Filter(mq.MatchQuery("category": "technology")),
- bq.Filter(mq.MatchQuery("tags": "go")),
- bq.Should(mq.MatchQuery("title": "elasticsearch")),
- bq.Should(mq.MatchQuery("content": "search optimization")),
- bq.MustNot(mq.MatchQuery("user.role": "banned")),
- bq.MustNot(mq.MatchQuery("status": "draft")),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ mq "github.com/sdqri/effdsl/queries/matchquery"
+ bq "github.com/sdqri/effdsl/queries/boolquery"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ bq.BoolQuery(
+ bq.Must(mq.MatchQuery(effdsl.M{"user.name": "john_doe"})),
+ bq.Must(mq.MatchQuery("post.status": "published")),
+ bq.Filter(mq.MatchQuery("category": "technology")),
+ bq.Filter(mq.MatchQuery("tags": "go")),
+ bq.Should(mq.MatchQuery("title": "elasticsearch")),
+ bq.Should(mq.MatchQuery("content": "search optimization")),
+ bq.MustNot(mq.MatchQuery("user.role": "banned")),
+ bq.MustNot(mq.MatchQuery("status": "draft")),
+ ),
+ ),
+)
+
+res, err := es.Search(
+ es.Search.WithBody(strings.NewReader(query)),
+)
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- bq "github.com/sdqri/effdsl/v2/queries/boostingquery"
- tq "github.com/sdqri/effdsl/v2/queries/termquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- bq.BoostingQuery(
- tq.TermQuery("text", "apple"),
- tq.TermQuery("text", "pie tart fruit crumble tree"),
- 0.5,
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ bq "github.com/sdqri/effdsl/queries/boostingquery"
+ tq "github.com/sdqri/effdsl/queries/termquery"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ bq.BoostingQuery(
+ tq.TermQuery("text", "apple"),
+ tq.TermQuery("text", "pie tart fruit crumble tree"),
+ 0.5),
+ ),
+)
+
+res, err := es.Search(
+ es.Search.WithBody(strings.NewReader(query)),
+)
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- csq "github.com/sdqri/effdsl/v2/queries/constantscore"
- tq "github.com/sdqri/effdsl/v2/queries/termquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- csq.ConstantScoreQuery(
- tq.TermQuery("user.id", "kimchy"),
- 1.2
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ csq "github.com/sdqri/effdsl/queries/constantscore"
+ tq "github.com/sdqri/effdsl/queries/termquery"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ csq.ConstantScoreQuery(
+ tq.TermQuery("user.id", "kimchy"),
+ 1.2),
+ ),
+)
+
+res, err := es.Search(
+ es.Search.WithBody(strings.NewReader(query)),
+)
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- dmq "github.com/sdqri/effdsl/v2/queries/dismaxquery"
- tq "github.com/sdqri/effdsl/v2/queries/termquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- dmq.DisMaxQuery(
- []effdsl.QueryResult{
- tq.TermQuery("title", "Quick pets"),
- tq.TermQuery("body", "Quick pets"),
- },
- dmq.WithTieBreaker(0.7),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ dmq "github.com/sdqri/effdsl/queries/dismaxquery"
+ tq "github.com/sdqri/effdsl/queries/termquery"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ dmq.DisMaxQuery(
+ []effdsl.QueryResult{
+ tq.TermQuery("title", "Quick pets"),
+ tq.TermQuery("body", "Quick pets"),
+ },
+ dmq.WithTieBreaker(0.7),
+ ),
+ ),
+)
+
+res, err := es.Search(
+ es.Search.WithBody(strings.NewReader(query)),
+)
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- eq "github.com/sdqri/effdsl/v2/queries/existsquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- eq.ExistsQuery("field_name"),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ eq "github.com/sdqri/effdsl/queries/existsquery"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ eq.ExistsQuery("field_name"),
+ ),
+)
+
+res, err := es.Search(
+ es.Search.WithBody(strings.NewReader(query)),
+)
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- eq "github.com/sdqri/effdsl/v2/queries/existsquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- fq.FuzzyQuery(
- "user.id",
- "ki",
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ eq "github.com/sdqri/effdsl/queries/existsquery"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ fq.FuzzyQuery(
+ "user.id",
+ "ki",
+ ),
+ ),
+)
+
+res, err := es.Search(
+ es.Search.WithBody(strings.NewReader(query)),
+)
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- iq "github.com/sdqri/effdsl/v2/queries/idsquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- iq.IDsQuery("1", "4", "100"),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ iq "github.com/sdqri/effdsl/queries/idsquery"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ iq.IDsQuery("1", "4", "100"),
+ ),
+)
+
+res, err := es.Search(
+ es.Search.WithBody(strings.NewReader(query)),
+)
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
+
How to use
Start with effdsl.Define()
, and use types and documentations to find suitable options.
@@ -1202,8 +1202,8 @@ 🔍 Examples:
query, err := effdsl.Define(
effdsl.WithQuery(
- mq.MatchQuery("message", "Hello World"),
- ),
+ mq.MatchQuery("message", "Hello World")
+ ),
)
res, err := es.Search(
diff --git a/docs/match_bool_prefix/index.html b/docs/match_bool_prefix/index.html
index adf2225..219c99b 100644
--- a/docs/match_bool_prefix/index.html
+++ b/docs/match_bool_prefix/index.html
@@ -1191,24 +1191,23 @@ Match Bool Prefix Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mbpq "github.com/sdqri/effdsl/v2/queries/matchboolprefix"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mbpq.MatchBoolPrefixQuery(
- "message",
- "quick brown f",
- mbpq.WithAnalyzer("keyword"),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ mbpq "github.com/sdqri/effdsl/queries/matchboolprefix"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ mbpq.MatchBoolPrefixQuery(
+ "message",
+ "quick brown f",
+ mbpq.WithAnalyzer("keyword"),
+ ),
+ ),
+)
+
+res, err := es.Search(
+ es.Search.WithBody(strings.NewReader(query)),
+)
Parameters
diff --git a/docs/match_phrase_prefix/index.html b/docs/match_phrase_prefix/index.html
index e1d9a62..0678d56 100644
--- a/docs/match_phrase_prefix/index.html
+++ b/docs/match_phrase_prefix/index.html
@@ -1191,26 +1191,25 @@ Match Phrase Prefix Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ mppq "github.com/sdqri/effdsl/queries/matchphraseprefixquery"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ mppq.MatchPhrasePrefixQuery(
+ "field_name",
+ "some phrase prefix query",
+ mppq.WithAnalyzer("my_analyzer"),
+ mppq.WithSlop(2),
+ mppq.WithMaxExpansions(10),
+ ),
+ ),
+)
+
+res, err := es.Search(
+ es.Search.WithBody(strings.NewReader(query)),
+)
Parameters
diff --git a/docs/match_phrase_query/index.html b/docs/match_phrase_query/index.html
index e61036b..e035f51 100644
--- a/docs/match_phrase_query/index.html
+++ b/docs/match_phrase_query/index.html
@@ -708,24 +708,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,26 +1191,23 @@ Match Phrase Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ mpq "github.com/sdqri/effdsl/queries/matchphrasequery"
+)
+
+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)),
+)
Parameters
@@ -1267,56 +1228,6 @@ Parameters
(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.
-
-
-
-Additional Information
-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"
-mpq "github.com/sdqri/effdsl/v2/queries/matchphrasequery"
-
-)
-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)),
-)
-```
-Parameters
-
--
-
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’s 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:
@@ -1325,7 +1236,7 @@ Parameters
-Additional Information
+Additional Information
For more details on the match phrase query and its parameters, refer to the official Elasticsearch documentation on match phrase queries.
diff --git a/docs/match_query/index.html b/docs/match_query/index.html
index 97adb1d..2a06eb0 100644
--- a/docs/match_query/index.html
+++ b/docs/match_query/index.html
@@ -666,24 +666,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,81 +1191,29 @@ Match Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mq "github.com/sdqri/effdsl/v2/queries/matchquery"
-)
-
-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)),
-)
+ "github.com/sdqri/effdsl/v2"
+ mq "github.com/sdqri/effdsl/queries/matchquery"
+)
+
+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)),
+)
Parameters
-
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’s 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.
-
-
-
-Additional Information
-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"
-mq "github.com/sdqri/effdsl/v2/queries/matchquery"
-
-)
-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)),
-)
-```
-Parameters
-
--
-
Field (string)
(Required, positional) The field you wish to search. This is a required parameter.
-
@@ -1353,7 +1265,7 @@
Parameters
(Optional, Functional option) Minimum number of clauses that must match for a document to be returned.
-Additional Information
+Additional Information
For more details on the match query and its parameters, refer to the official Elasticsearch documentation on match queries.
diff --git a/docs/prefix_query/index.html b/docs/prefix_query/index.html
index 88cd5a8..bd5e228 100644
--- a/docs/prefix_query/index.html
+++ b/docs/prefix_query/index.html
@@ -923,24 +923,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,80 +1191,27 @@ Prefix Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
- ),
- ),
+ "github.com/sdqri/effdsl/v2"
+ pq "github.com/sdqri/effdsl/queries/prefixquery"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ pq.PrefixQuery(
+ "name",
+ "al",
+ ),
+ ),
+)
+
+res, err := es.Search(
+ es.Search.WithBody(strings.NewReader(query)),
)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
Parameters
-
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’s 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.
-
-
-
-Additional Information
-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"
-pq "github.com/sdqri/effdsl/v2/queries/prefixquery"
-
-)
-query, err := effdsl.Define(
- effdsl.WithQuery(
- pq.PrefixQuery(
- "name",
- "al",
- ),
- ),
-)
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
-```
-Parameters
-
--
-
Field (string)
(Required, positional) The field you wish to search. This is a required parameter.
-
@@ -1324,7 +1235,7 @@
Parameters
(Optional, Functional option) Whether the query is case insensitive. Defaults to false.
-Additional Information
+Additional Information
For more details on the prefix query and its parameters, refer to the official Elasticsearch documentation on prefix queries.
diff --git a/docs/query_string/index.html b/docs/query_string/index.html
index 88ee0a4..b859f5e 100644
--- a/docs/query_string/index.html
+++ b/docs/query_string/index.html
@@ -750,24 +750,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,81 +1191,28 @@ Query String Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ qs "github.com/sdqri/effdsl/queries/querystring"
+)
+
+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)),
+)
Parameters
-
-
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’s 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.
-
-
-
-Additional Information
-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"
-qs "github.com/sdqri/effdsl/v2/queries/querystring"
-
-)
-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)),
-)
-```
-Parameters
-
--
Query (string)
(Required, positional) The query string to parse and use for search. This is a required parameter.
@@ -1402,7 +1313,7 @@ Parameters
(Optional, Functional option) UTC offset or IANA time zone used to convert date values in the query string to UTC.
-Additional Information
+Additional Information
For more details on the query string query and its parameters, refer to the official Elasticsearch documentation on query string queries.
diff --git a/docs/range_query/index.html b/docs/range_query/index.html
index b6996ac..8775b21 100644
--- a/docs/range_query/index.html
+++ b/docs/range_query/index.html
@@ -944,24 +944,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,82 +1191,29 @@ Range Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ rq "github.com/sdqri/effdsl/queries/rangequery"
+)
+
+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)),
+)
Parameters
-
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’s 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.
-
-
-
-Additional Information
-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"
-rq "github.com/sdqri/effdsl/v2/queries/rangequery"
-
-)
-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)),
-)
-```
-Parameters
-
--
-
Field (string)
(Required, positional) The field you wish to search. This is a required parameter.
-
@@ -1343,7 +1254,7 @@
Parameters
(Optional, Functional option) Floating point number used to decrease or increase the relevance scores of the query. Defaults to 1.0.
-Additional Information
+Additional Information
For more details on the range query and its parameters, refer to the official Elasticsearch documentation on range queries.
diff --git a/docs/regexp_query/index.html b/docs/regexp_query/index.html
index 33f2de3..ebeb822 100644
--- a/docs/regexp_query/index.html
+++ b/docs/regexp_query/index.html
@@ -965,24 +965,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,19 +1191,19 @@ Regexp Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
+ "github.com/sdqri/effdsl/v2"
+ rq "github.com/sdqri/effdsl/queries/regexpquery"
+)
+
+query, err := effdsl.Define(
+ effdsl.WithQuery(
+ rq.RegexpQuery(
+ "user.id",
+ "k.*y",
+ rq.WithFlags("ALL"),
+ rq.WithCaseInsensitive(),
+ rq.WithMaxDeterminizedStates(10000),
+ rq.WithRQRewrite(rq.ConstantScore),
),
),
)
@@ -1252,59 +1216,6 @@ Parameters
-
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’s 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.
-
-
-
-Additional Information
-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"
-rq "github.com/sdqri/effdsl/v2/queries/regexpquery"
-
-)
-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)),
-)
-```
-Parameters
-
--
-
Field (string)
(Required, positional) The field you wish to search. This is a required parameter.
-
@@ -1336,7 +1247,7 @@
Parameters
-Additional Information
+Additional Information
For more details on the regexp query and its parameters, refer to the official Elasticsearch documentation on regexp queries.
diff --git a/docs/search/search_index.json b/docs/search/search_index.json
index 3882155..d16555a 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/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
+{"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\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 \"github.com/sdqri/effdsl/v2\"\n mq \"github.com/sdqri/effdsl/queries/matchquery\"\n bq \"github.com/sdqri/effdsl/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 \"github.com/sdqri/effdsl/v2\"\n bq \"github.com/sdqri/effdsl/queries/boostingquery\"\n tq \"github.com/sdqri/effdsl/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\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 \"github.com/sdqri/effdsl/v2\"\n csq \"github.com/sdqri/effdsl/queries/constantscore\"\n tq \"github.com/sdqri/effdsl/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\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 \"github.com/sdqri/effdsl/v2\"\n dmq \"github.com/sdqri/effdsl/queries/dismaxquery\"\n tq \"github.com/sdqri/effdsl/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 \"github.com/sdqri/effdsl/v2\"\n eq \"github.com/sdqri/effdsl/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 \"github.com/sdqri/effdsl/v2\"\n eq \"github.com/sdqri/effdsl/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 \"github.com/sdqri/effdsl/v2\"\n iq \"github.com/sdqri/effdsl/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 \"github.com/sdqri/effdsl/v2\"\n mbpq \"github.com/sdqri/effdsl/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 \"github.com/sdqri/effdsl/v2\"\n mppq \"github.com/sdqri/effdsl/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 \"github.com/sdqri/effdsl/v2\"\n mpq \"github.com/sdqri/effdsl/queries/matchphrasequery\"\n)\n\nquery, err := effdsl.Define(\n effdsl.WithQuery(\n mpq.MatchPhraseQuery(\n \"field_name\",\n \"some phrase query\",\n mpq.WithAnalyzer(\"my_analyzer\"),\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.
-
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 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 \"github.com/sdqri/effdsl/v2\"\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 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","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 \"github.com/sdqri/effdsl/v2\"\n pq \"github.com/sdqri/effdsl/queries/prefixquery\"\n)\n\nquery, err := effdsl.Define(\n effdsl.WithQuery(\n pq.PrefixQuery(\n \"name\",\n \"al\",\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 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","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 \"github.com/sdqri/effdsl/v2\"\n qs \"github.com/sdqri/effdsl/queries/querystring\"\n)\n\nquery, err := effdsl.Define(\n effdsl.WithQuery(\n qs.QueryString(\n \"alice\",\n qs.WithFields(\"first_name\", \"last_name\")\n qs.WithBoost(1.5),\n qs.WithFuzziness(\"AUTO\"),\n ),\n ),\n)\n\nres, err := es.Search(\n es.Search.WithBody(strings.NewReader(query)),\n)\n
"},{"location":"query_string/#parameters","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","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 \"github.com/sdqri/effdsl/v2\"\n rq \"github.com/sdqri/effdsl/queries/rangequery\"\n)\n\nquery, err := effdsl.Define(\n effdsl.WithQuery(\n rq.RangeQuery(\n \"age\",\n rq.WithGT(10),\n rq.WithLTE(20),\n rq.WithBoost(2.0),\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 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","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 \"github.com/sdqri/effdsl/v2\"\n rq \"github.com/sdqri/effdsl/queries/regexpquery\"\n)\n\nquery, err := effdsl.Define(\n effdsl.WithQuery(\n rq.RegexpQuery(\n \"user.id\",\n \"k.*y\",\n rq.WithFlags(\"ALL\"),\n rq.WithCaseInsensitive(),\n rq.WithMaxDeterminizedStates(10000),\n rq.WithRQRewrite(rq.ConstantScore),\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 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","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 \"github.com/sdqri/effdsl/v2\"\n sqs \"github.com/sdqri/effdsl/queries/simplequerystring\"\n)\n\nquery, err := effdsl.Define(\n effdsl.WithQuery(\n sqs.SimpleQueryString(\n `\"fried eggs\" +(eggplant | potato) -frittata`,\n sqs.WithFields(\"title^5\", \"body\"),\n sqs.WithDefaultOperator(sqs.AND),\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":" -
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","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 \"github.com/sdqri/effdsl/v2\"\n tq \"github.com/sdqri/effdsl/queries/termquery\"\n)\n\nquery, err := effdsl.Define(\n effdsl.WithQuery(\n tq.TermQuery(\n \"user.id\",\n \"kimchy\",\n tq.WithBoost(1.5),\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 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","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 \"github.com/sdqri/effdsl/v2\"\n tsq \"github.com/sdqri/effdsl/queries/termsquery\"\n)\n\nquery, err := effdsl.Define(\n effdsl.WithQuery(\n tsq.TermsQuery(\n \"user.id\",\n []string{\"kimchy\", \"elkbee\"},\n tsq.WithBoost(1.0),\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 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","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 \"github.com/sdqri/effdsl/v2\"\n tsq \"github.com/sdqri/effdsl/queries/termssetquery\"\n)\n\nquery, err := effdsl.Define(\n effdsl.WithQuery(\n tsq.TermsSetQuery(\n \"programming_languages\",\n []string{\"c++\", \"java\", \"php\"},\n tsq.WithMinimumShouldMatchField(\"required_matches\"),\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 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","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 \"github.com/sdqri/effdsl/v2\"\n wq \"github.com/sdqri/effdsl/queries/wildcardquery\"\n)\n\nquery, err := effdsl.Define(\n effdsl.WithQuery(\n wq.WildcardQuery(\n \"user.id\",\n \"ki*y\",\n wq.WithBoost(1.0),\n wq.WithRewrite(wcq.ConstantScoreBlended),\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 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","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/simple_query_string/index.html b/docs/simple_query_string/index.html
index 1a7a0de..4008c17 100644
--- a/docs/simple_query_string/index.html
+++ b/docs/simple_query_string/index.html
@@ -771,24 +771,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,80 +1191,27 @@ Simple Query String
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ sqs "github.com/sdqri/effdsl/queries/simplequerystring"
+)
+
+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)),
+)
Parameters
-
-
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’s 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.
-
-
-
-Additional Information
-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"
-sqs "github.com/sdqri/effdsl/v2/queries/simplequerystring"
-
-)
-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)),
-)
-```
-Parameters
-
--
Query (string)
(Required, positional) The query string you wish to parse and use for search. This is a required parameter.
@@ -1357,7 +1268,7 @@ Parameters
(Optional, Functional option) Suffix appended to quoted text in the query string.
-Additional Information
+Additional Information
For more details on the simple query string query and its parameters, refer to the official Elasticsearch documentation on simple query string queries.
diff --git a/docs/sitemap.xml b/docs/sitemap.xml
index d6e7b4e..d683b5d 100644
--- a/docs/sitemap.xml
+++ b/docs/sitemap.xml
@@ -2,117 +2,117 @@
https://sdqri.org/effdsl/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/api_coverage/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/bool_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/boosting_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/constant_score/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/dis_max_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/exists_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/fuzzy_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/ids_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/match_bool_prefix/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/match_phrase_prefix/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/match_phrase_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/match_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/prefix_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/query_string/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/range_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/regexp_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/release_notes/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/simple_query_string/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/term_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/terms_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/terms_set_query/
- 2024-08-22
+ 2024-09-23
daily
https://sdqri.org/effdsl/wildcard_query/
- 2024-08-22
+ 2024-09-23
daily
\ No newline at end of file
diff --git a/docs/sitemap.xml.gz b/docs/sitemap.xml.gz
index 69d5fa5..01de04e 100644
Binary files a/docs/sitemap.xml.gz and b/docs/sitemap.xml.gz differ
diff --git a/docs/term_query/index.html b/docs/term_query/index.html
index 4344aa3..dbb0ec9 100644
--- a/docs/term_query/index.html
+++ b/docs/term_query/index.html
@@ -986,24 +986,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,81 +1191,28 @@ Term Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ tq "github.com/sdqri/effdsl/queries/termquery"
+)
+
+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)),
+)
Parameters
-
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’s 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.
-
-
-
-Additional Information
-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"
-tq "github.com/sdqri/effdsl/v2/queries/termquery"
-
-)
-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)),
-)
-```
-Parameters
-
--
-
Field (string)
(Required, positional) The field you wish to search. This is a required parameter.
-
@@ -1317,7 +1228,7 @@
Parameters
(Optional, Functional option) Allows ASCII case-insensitive matching of the value with the indexed field values when set to true. Defaults to false.
-Additional Information
+Additional Information
For more details on the term query and its parameters, refer to the official Elasticsearch documentation on term queries.
diff --git a/docs/terms_query/index.html b/docs/terms_query/index.html
index 8778ee8..9f59dc7 100644
--- a/docs/terms_query/index.html
+++ b/docs/terms_query/index.html
@@ -1007,24 +1007,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,81 +1191,28 @@ Terms Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ tsq "github.com/sdqri/effdsl/queries/termsquery"
+)
+
+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)),
+)
Parameters
-
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’s 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.
-
-
-
-Additional Information
-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"
-tsq "github.com/sdqri/effdsl/v2/queries/termsquery"
-
-)
-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)),
-)
-```
-Parameters
-
--
-
Field (string)
(Required, positional) The field you wish to search. This is a required parameter.
-
@@ -1313,7 +1224,7 @@
Parameters
(Optional, Functional option) Floating point number used to decrease or increase the relevance scores of a query. Defaults to 1.0.
-Additional Information
+Additional Information
For more details on the terms query and its parameters, refer to the official Elasticsearch documentation on terms queries.
diff --git a/docs/terms_set_query/index.html b/docs/terms_set_query/index.html
index 4e6cb51..dcf5e59 100644
--- a/docs/terms_set_query/index.html
+++ b/docs/terms_set_query/index.html
@@ -1028,24 +1028,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,81 +1191,28 @@ Terms Set Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ tsq "github.com/sdqri/effdsl/queries/termssetquery"
+)
+
+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)),
+)
Parameters
-
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’s 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.
-
-
-
-Additional Information
-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"
-tsq "github.com/sdqri/effdsl/v2/queries/termssetquery"
-
-)
-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)),
-)
-```
-Parameters
-
--
-
Field (string)
(Required, positional) The field you wish to search. This is a required parameter.
-
@@ -1317,7 +1228,7 @@
Parameters
(Optional, Functional option) Script that returns the minimum number of terms that should match.
-Additional Information
+Additional Information
For more details on the term set query and its parameters, refer to the official Elasticsearch documentation on term set queries.
diff --git a/docs/wildcard_query/index.html b/docs/wildcard_query/index.html
index a8e3ba4..1b7e17f 100644
--- a/docs/wildcard_query/index.html
+++ b/docs/wildcard_query/index.html
@@ -1049,24 +1049,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1184,24 +1166,6 @@
-
-
- -
-
-
- Parameters
-
-
-
-
-
- -
-
-
- Additional Information
-
-
-
@@ -1227,82 +1191,29 @@ Wildcard Query
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
-
- "github.com/sdqri/effdsl/v2"
- mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
-)
-
-query, err := effdsl.Define(
- effdsl.WithQuery(
- mppq.MatchPhrasePrefixQuery(
- "field_name",
- "some phrase prefix query",
- mppq.WithAnalyzer("my_analyzer"),
- mppq.WithSlop(2),
- mppq.WithMaxExpansions(10),
- ),
- ),
-)
-
-res, err := es.Search(
- es.Search.WithBody(strings.NewReader(query)),
-)
+ "github.com/sdqri/effdsl/v2"
+ wq "github.com/sdqri/effdsl/queries/wildcardquery"
+)
+
+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)),
+)
Parameters
-
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’s 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.
-
-
-
-Additional Information
-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"
-wq "github.com/sdqri/effdsl/v2/queries/wildcardquery"
-
-)
-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)),
-)
-```
-Parameters
-
--
-
Field (string)
(Required, positional) The field you wish to search. This is a required parameter.
-
@@ -1322,7 +1233,7 @@
Parameters
(Optional, Functional option) Method used to rewrite the query. For valid values and more information, see the rewrite parameter.
-Additional Information
+Additional Information
For more details on the wildcard query and its parameters, refer to the official Elasticsearch documentation on wildcard queries.