jfmmm
jfmmm

Reputation: 391

How to see the analyzed data that was indexed?

How do you see the analyzed data that is stored after you index something.

I know you can just do a search to see it like this

http://localhost:9200/local_products_fr/fields/_search/

But what I want to see is the actual data not the _source

something like what you get when you call _analyzer

http://localhost:9200/local_products_fr/_analyze?text=<p>my <b>super</b> text</p>&analyzer=analyzer_fr

{
  "tokens": [
    {
      "token": "my",
      "start_offset": 3,
      "end_offset": 5,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "b",
      "start_offset": 7,
      "end_offset": 8,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "sup",
      "start_offset": 9,
      "end_offset": 14,
      "type": "<ALPHANUM>",
      "position": 2
    },
    {
      "token": "b",
      "start_offset": 16,
      "end_offset": 17,
      "type": "<ALPHANUM>",
      "position": 3
    },
    {
      "token": "text",
      "start_offset": 19,
      "end_offset": 23,
      "type": "<ALPHANUM>",
      "position": 4
    }
  ]
}

Upvotes: 2

Views: 813

Answers (1)

user3775217
user3775217

Reputation: 4803

i use this to get inverted index for a field per document

{
    "query": {
        "bool": {
            "must": [{
                "term": {
                    "_id": {
                        "value": "2"
                    }
                }
            }]
        }
    },
    "script_fields": {
        "terms": {
            "script": "doc['product.name'].values"
        }
    }
}

Hope this works for you

Upvotes: 2

Related Questions