2018-11-27 20:40:49 -05:00
|
|
|
--
|
|
|
|
:api: analyze
|
|
|
|
:request: AnalyzeRequest
|
|
|
|
:response: AnalyzeResponse
|
|
|
|
--
|
|
|
|
|
|
|
|
[id="{upid}-{api}"]
|
2018-07-03 10:57:02 -04:00
|
|
|
=== Analyze API
|
|
|
|
|
2018-11-27 20:40:49 -05:00
|
|
|
[id="{upid}-{api}-request"]
|
2018-07-03 10:57:02 -04:00
|
|
|
==== Analyze Request
|
|
|
|
|
2018-11-27 20:40:49 -05:00
|
|
|
An +{request}+ contains the text to analyze, and one of several options to
|
2018-07-03 10:57:02 -04:00
|
|
|
specify how the analysis should be performed.
|
|
|
|
|
|
|
|
The simplest version uses a built-in analyzer:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
---------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-builtin-request]
|
2018-07-03 10:57:02 -04:00
|
|
|
---------------------------------------------------
|
|
|
|
<1> The text to include. Multiple strings are treated as a multi-valued field
|
|
|
|
<2> A built-in analyzer
|
|
|
|
|
|
|
|
You can configure a custom analyzer:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
---------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-custom-request]
|
2018-07-03 10:57:02 -04:00
|
|
|
---------------------------------------------------
|
|
|
|
<1> Configure char filters
|
|
|
|
<2> Configure the tokenizer
|
|
|
|
<3> Add a built-in tokenfilter
|
|
|
|
<4> Configuration for a custom tokenfilter
|
|
|
|
<5> Add the custom tokenfilter
|
|
|
|
|
|
|
|
You can also build a custom normalizer, by including only charfilters and
|
|
|
|
tokenfilters:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
---------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-custom-normalizer-request]
|
2018-07-03 10:57:02 -04:00
|
|
|
---------------------------------------------------
|
|
|
|
|
|
|
|
You can analyze text using an analyzer defined in an existing index:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
---------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-index-request]
|
2018-07-03 10:57:02 -04:00
|
|
|
---------------------------------------------------
|
|
|
|
<1> The index containing the mappings
|
|
|
|
<2> The analyzer defined on this index to use
|
|
|
|
|
|
|
|
Or you can use a normalizer:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
---------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-index-normalizer-request]
|
2018-07-03 10:57:02 -04:00
|
|
|
---------------------------------------------------
|
|
|
|
<1> The index containing the mappings
|
|
|
|
<2> The normalizer defined on this index to use
|
|
|
|
|
|
|
|
You can analyze text using the mappings for a particular field in an index:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
---------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-field-request]
|
2018-07-03 10:57:02 -04:00
|
|
|
---------------------------------------------------
|
|
|
|
|
2018-07-06 04:05:34 -04:00
|
|
|
==== Optional arguments
|
2018-07-03 10:57:02 -04:00
|
|
|
The following arguments can also optionally be provided:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
---------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-request-explain]
|
2018-07-03 10:57:02 -04:00
|
|
|
---------------------------------------------------
|
|
|
|
<1> Setting `explain` to true will add further details to the response
|
|
|
|
<2> Setting `attributes` allows you to return only token attributes that you are
|
|
|
|
interested in
|
|
|
|
|
2018-11-27 20:40:49 -05:00
|
|
|
include::../execution.asciidoc[]
|
2018-07-03 10:57:02 -04:00
|
|
|
|
2018-11-27 20:40:49 -05:00
|
|
|
[id="{upid}-{api}-response"]
|
2018-07-03 10:57:02 -04:00
|
|
|
==== Analyze Response
|
|
|
|
|
2018-11-27 20:40:49 -05:00
|
|
|
The returned +{response}+ allows you to retrieve details of the analysis as
|
2018-07-03 10:57:02 -04:00
|
|
|
follows:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
---------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-response-tokens]
|
2018-07-03 10:57:02 -04:00
|
|
|
---------------------------------------------------
|
|
|
|
<1> `AnalyzeToken` holds information about the individual tokens produced by analysis
|
|
|
|
|
|
|
|
If `explain` was set to `true`, then information is instead returned from the `detail()`
|
|
|
|
method:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
---------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-response-detail]
|
2018-07-03 10:57:02 -04:00
|
|
|
---------------------------------------------------
|
|
|
|
<1> `DetailAnalyzeResponse` holds more detailed information about tokens produced by
|
|
|
|
the various substeps in the analysis chain.
|