analyze.asciidoc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. [[indices-analyze]]
  2. == Analyze
  3. Performs the analysis process on a text and return the tokens breakdown
  4. of the text.
  5. Can be used without specifying an index against one of the many built in
  6. analyzers:
  7. [source,js]
  8. --------------------------------------------------
  9. curl -XGET 'localhost:9200/_analyze?analyzer=standard' -d 'this is a test'
  10. --------------------------------------------------
  11. Or by building a custom transient analyzer out of tokenizers,
  12. token filters and char filters. Token filters can use the shorter 'filters'
  13. parameter name:
  14. [source,js]
  15. --------------------------------------------------
  16. curl -XGET 'localhost:9200/_analyze?tokenizer=keyword&filters=lowercase' -d 'this is a test'
  17. curl -XGET 'localhost:9200/_analyze?tokenizer=keyword&token_filters=lowercase&char_filters=html_strip' -d 'this is a <b>test</b>'
  18. --------------------------------------------------
  19. It can also run against a specific index:
  20. [source,js]
  21. --------------------------------------------------
  22. curl -XGET 'localhost:9200/test/_analyze?text=this+is+a+test'
  23. --------------------------------------------------
  24. The above will run an analysis on the "this is a test" text, using the
  25. default index analyzer associated with the `test` index. An `analyzer`
  26. can also be provided to use a different analyzer:
  27. [source,js]
  28. --------------------------------------------------
  29. curl -XGET 'localhost:9200/test/_analyze?analyzer=whitespace' -d 'this is a test'
  30. --------------------------------------------------
  31. Also, the analyzer can be derived based on a field mapping, for example:
  32. [source,js]
  33. --------------------------------------------------
  34. curl -XGET 'localhost:9200/test/_analyze?field=obj1.field1' -d 'this is a test'
  35. --------------------------------------------------
  36. Will cause the analysis to happen based on the analyzer configured in the
  37. mapping for `obj1.field1` (and if not, the default index analyzer).
  38. Also, the text can be provided as part of the request body, and not as a
  39. parameter.