Skip to content

Commit 50ed1d0

Browse files
authored
[DOCS] Adds reference documentation to the text expansion query (#96151) (#96187)
1 parent dcd9049 commit 50ed1d0

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

docs/reference/query-dsl.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ include::query-dsl/special-queries.asciidoc[]
8080

8181
include::query-dsl/term-level-queries.asciidoc[]
8282

83+
include::query-dsl/text-expansion-query.asciidoc[]
84+
8385
include::query-dsl/minimum-should-match.asciidoc[]
8486

8587
include::query-dsl/multi-term-rewrite.asciidoc[]
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
[[query-dsl-text-expansion-query]]
2+
== Text expansion query
3+
++++
4+
<titleabbrev>Text expansion</titleabbrev>
5+
++++
6+
7+
The text expansion query uses a {nlp} model to convert the query text into a
8+
list of token-weight pairs which are then used in a query against a
9+
<<rank-features,rank features field>>.
10+
11+
[discrete]
12+
[[text-expansion-query-ex-request]]
13+
=== Example request
14+
15+
16+
[source,console]
17+
----
18+
GET _search
19+
{
20+
"query":{
21+
"text_expansion":{
22+
"<rank_features_field>":{
23+
"model_id":"the model to produce the token weights",
24+
"model_text":"the query string"
25+
}
26+
}
27+
}
28+
}
29+
----
30+
// TEST[skip: TBD]
31+
32+
[discrete]
33+
[[text-expansion-query-params]]
34+
=== Top level parameters for `text_expansion`
35+
36+
`<rank_features_field>`:::
37+
(Required, object)
38+
The name of the field that contains the token-weight pairs the NLP model created
39+
based on the input text.
40+
41+
[discrete]
42+
[[text-expansion-rank-feature-field-params]]
43+
=== Top level parameters for `<rank_features_field>`
44+
45+
`model_id`::::
46+
(Required, string)
47+
The ID of the model to use to convert the query text into token-weight pairs. It
48+
must be the same model ID that was used to create the tokens from the input
49+
text.
50+
51+
`model_text`::::
52+
(Required, string)
53+
The query text you want to use for search.
54+
55+
56+
[discrete]
57+
[[text-expansion-query-notes]]
58+
=== Notes
59+
60+
The following is an example of the `text_expansion` query that references the
61+
ELSER model to perform semantic search. For a more detailed description of how
62+
to perform semantic search by using ELSER and the `text_expansion` query, refer
63+
to <<semantic-search-elser,this tutorial>>.
64+
65+
[source,console]
66+
----
67+
GET my-index/_search
68+
{
69+
"query":{
70+
"text_expansion":{
71+
"ml.tokens":{
72+
"model_id":".elser_model_1",
73+
"model_text":"How is the weather in Jamaica?"
74+
}
75+
}
76+
}
77+
}
78+
----
79+
// TEST[skip: TBD]

0 commit comments

Comments
 (0)