66

I configured a custom analyzer and put some documents into the index. Now I want to debug my settings so I can see which n-grams actually made it into the index.

When I used Solr before, there was a possibility to see which strings were saved in the index as keys and also their frequency.

fqxp
  • 7,680
  • 3
  • 24
  • 41
  • 1
    Are you looking for the [Analyze API](http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze.html)? – Thorsten Jan 28 '13 at 16:40
  • @Thorsten: no, it's helpful, but it doesn't show the actual index content. I'd like to see if my configuration does what I think it should. Thanks for the hint anyway. – fqxp Jan 28 '13 at 16:47
  • The above link is taking to home page of elastic. Thanks for the API though. Link to analyze api : https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html – User3518958 Sep 05 '19 at 12:39

4 Answers4

61

You can view any existing index by using the below CURL. Please replace the index-name with your actual name before running and it will run as is.

View the index content

curl -H 'Content-Type: application/json' -X GET https://localhost:9200/index_name?pretty

And the output will include an index(see settings in output) and its mappings too and it will look like below output -

{
  "index_name": {
    "aliases": {},
    "mappings": {
      "collection_name": {
        "properties": {
          "test_field": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
       }
    },
    "settings": {
      "index": {
        "creation_date": "1527377274366",
        "number_of_shards": "5",
        "number_of_replicas": "1",
        "uuid": "6QfKqbbVQ0Gbsqkq7WZJ2g",
        "version": {
          "created": "6020299"
        },
        "provided_name": "index_name"
      }
    }
  }
}

View ALL the data under this index

curl -H 'Content-Type: application/json' -X GET https://localhost:9200/index_name/_search?pretty
Ash
  • 1,210
  • 1
  • 10
  • 14
12

If you didn't index too much data into the index yet, you can use term facet query on the field that you would like to debug to see the tokens and their frequencies:

curl -XDELETE 'http://localhost:9200/test-idx'
echo
curl -XPUT 'http://localhost:9200/test-idx' -d '
{
    "settings": {
        "index.number_of_shards" : 1,
        "index.number_of_replicas": 0
    },
    "mappings": {            
        "doc": {
            "properties": {
                "message": {"type": "string", "analyzer": "snowball"}
            }
        }
    }

}'
echo
curl -XPUT 'http://localhost:9200/test-idx/doc/1' -d '
{
  "message": "How is this going to be indexed?"
}
'
echo
curl -XPOST 'http://localhost:9200/test-idx/_refresh'
echo
curl -XGET 'http://localhost:9200/test-idx/doc/_search?pretty=true&search_type=count' -d '{
    "query": {
        "match": {
            "_id": "1"
        }
    },
    "facets": {
        "tokens": {
            "terms": {
                "field": "message"
            }
        }
    }
}
'
echo
imotov
  • 28,277
  • 3
  • 90
  • 82
10

I can recommend Elasticvue, which is modern, free and open source. It allows accessing your ES instance via browser add-ons quite easily (supports Firefox, Chrome, Edge). But there are also further ways.

Just make sure you set cors values in elasticsearch.yml appropiate.

robsch
  • 9,358
  • 9
  • 63
  • 104
1

You can even add the size of the terms (indexed terms). Have a look at Elastic Search: how to see the indexed data

Community
  • 1
  • 1
Venkata Naresh
  • 377
  • 1
  • 2
  • 9