Search code examples
c#elasticsearchnestshingles

Elasticsearch 2.x - Return a list of shingles


I have a field "searchtext" that I have provided a sub-field "shingle" and I indexing that searchtext field with a shingles filter.

I need to get the list of shingles created for that field so that I can do some operations on that field. When I retrieve the "searchtext.shingle" field, it just contains the original text.

Does that mean the shingle analyzer that I setup was not working, or that the I need to get the list of shingles back in a different way?


Solution

  • You can retrieve all the terms of your "shingled" field using the _termvectors endpoint like this:

    curl -XGET 'http://localhost:9200/your_index/your_type/1/_termvectors?pretty=true' -d '{
      "fields" : ["searchtext.shingle"],
      "offsets" : true,
      "payloads" : true,
      "positions" : true,
      "term_statistics" : true,
      "field_statistics" : true
    }'