mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-08 03:49:38 +00:00
CONSOLify indices/analyze.asciidoc and search/field-stats.asciidoc
Relates #23001
This commit is contained in:
parent
adc1184dd0
commit
bbf62e3472
@ -110,7 +110,6 @@ buildRestTests.expectedUnconvertedCandidates = [
|
||||
'reference/index-modules/similarity.asciidoc',
|
||||
'reference/index-modules/store.asciidoc',
|
||||
'reference/index-modules/translog.asciidoc',
|
||||
'reference/indices/analyze.asciidoc',
|
||||
'reference/indices/flush.asciidoc',
|
||||
'reference/indices/get-settings.asciidoc',
|
||||
'reference/indices/put-mapping.asciidoc',
|
||||
|
@ -9,23 +9,25 @@ analyzers:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET 'localhost:9200/_analyze' -d '
|
||||
GET _analyze
|
||||
{
|
||||
"analyzer" : "standard",
|
||||
"text" : "this is a test"
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
If text parameter is provided as array of strings, it is analyzed as a multi-valued field.
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET 'localhost:9200/_analyze' -d '
|
||||
GET _analyze
|
||||
{
|
||||
"analyzer" : "standard",
|
||||
"text" : ["this is a test", "the second text"]
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
Or by building a custom transient analyzer out of tokenizers,
|
||||
token filters and char filters. Token filters can use the shorter 'filter'
|
||||
@ -33,21 +35,26 @@ parameter name:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET 'localhost:9200/_analyze' -d '
|
||||
GET _analyze
|
||||
{
|
||||
"tokenizer" : "keyword",
|
||||
"filter" : ["lowercase"],
|
||||
"text" : "this is a test"
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
curl -XGET 'localhost:9200/_analyze' -d '
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
GET _analyze
|
||||
{
|
||||
"tokenizer" : "keyword",
|
||||
"filter" : ["lowercase"],
|
||||
"char_filter" : ["html_strip"],
|
||||
"text" : "this is a <b>test</b>"
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
deprecated[5.0.0, Use `filter`/`char_filter` instead of `filters`/`char_filters` and `token_filters` has been removed]
|
||||
|
||||
@ -55,23 +62,26 @@ Custom tokenizers, token filters, and character filters can be specified in the
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET 'localhost:9200/_analyze' -d '
|
||||
GET _analyze
|
||||
{
|
||||
"tokenizer" : "whitespace",
|
||||
"filter" : ["lowercase", {"type": "stop", "stopwords": ["a", "is", "this"]}],
|
||||
"text" : "this is a test"
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
It can also run against a specific index:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET 'localhost:9200/test/_analyze' -d '
|
||||
GET twitter/_analyze
|
||||
{
|
||||
"text" : "this is a test"
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[setup:twitter]
|
||||
|
||||
The above will run an analysis on the "this is a test" text, using the
|
||||
default index analyzer associated with the `test` index. An `analyzer`
|
||||
@ -79,23 +89,27 @@ can also be provided to use a different analyzer:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET 'localhost:9200/test/_analyze' -d '
|
||||
GET twitter/_analyze
|
||||
{
|
||||
"analyzer" : "whitespace",
|
||||
"text" : "this is a test"
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[setup:twitter]
|
||||
|
||||
Also, the analyzer can be derived based on a field mapping, for example:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET 'localhost:9200/test/_analyze' -d '
|
||||
GET twitter/_analyze
|
||||
{
|
||||
"field" : "obj1.field1",
|
||||
"text" : "this is a test"
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[setup:twitter]
|
||||
|
||||
Will cause the analysis to happen based on the analyzer configured in the
|
||||
mapping for `obj1.field1` (and if not, the default index analyzer).
|
||||
|
@ -16,15 +16,18 @@ All indices:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET "http://localhost:9200/_field_stats?fields=rating"
|
||||
GET _field_stats?fields=rating
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
Specific indices:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET "http://localhost:9200/index1,index2/_field_stats?fields=rating"
|
||||
GET twitter/_field_stats?fields=rating
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[setup:twitter]
|
||||
|
||||
Supported request options:
|
||||
|
||||
@ -38,10 +41,12 @@ Alternatively the `fields` option can also be defined in the request body:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XPOST "http://localhost:9200/_field_stats?level=indices" -d '{
|
||||
POST _field_stats?level=indices
|
||||
{
|
||||
"fields" : ["rating"]
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
This is equivalent to the previous request.
|
||||
|
||||
@ -114,8 +119,9 @@ Request:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET "http://localhost:9200/_field_stats?fields=rating,answer_count,creation_date,display_name"
|
||||
GET _field_stats?fields=rating,answer_count,creation_date,display_name
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
Response:
|
||||
|
||||
@ -226,8 +232,9 @@ Request:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XGET "http://localhost:9200/_field_stats?fields=rating,answer_count,creation_date,display_name&level=indices"
|
||||
GET _field_stats?fields=rating,answer_count,creation_date,display_name&level=indices
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
Response:
|
||||
|
||||
@ -307,8 +314,9 @@ holding questions created in the year 2014:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XPOST "http://localhost:9200/_field_stats?level=indices" -d '{
|
||||
"fields" : ["answer_count"] <1>
|
||||
POST _field_stats?level=indices
|
||||
{
|
||||
"fields" : ["answer_count"], <1>
|
||||
"index_constraints" : { <2>
|
||||
"creation_date" : { <3>
|
||||
"max_value" : { <4>
|
||||
@ -319,8 +327,9 @@ curl -XPOST "http://localhost:9200/_field_stats?level=indices" -d '{
|
||||
}
|
||||
}
|
||||
}
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
<1> The fields to compute and return field stats for.
|
||||
<2> The set index constraints. Note that index constrains can be defined for fields that aren't defined in the `fields` option.
|
||||
@ -341,8 +350,9 @@ If missing, the format configured in the field's mapping is used.
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
curl -XPOST "http://localhost:9200/_field_stats?level=indices" -d '{
|
||||
"fields" : ["answer_count"]
|
||||
POST _field_stats?level=indices
|
||||
{
|
||||
"fields" : ["answer_count"],
|
||||
"index_constraints" : {
|
||||
"creation_date" : {
|
||||
"max_value" : {
|
||||
@ -355,7 +365,8 @@ curl -XPOST "http://localhost:9200/_field_stats?level=indices" -d '{
|
||||
}
|
||||
}
|
||||
}
|
||||
}'
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
<1> Custom date format
|
||||
|
Loading…
x
Reference in New Issue
Block a user