68

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.

3
  • 1
    Are you looking for the Analyze API?
    – Thorsten
    Jan 28, 2013 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, 2013 at 16:47
  • The above link is taking to home page of elastic. Thanks for the API though. Link to analyze api : elastic.co/guide/en/elasticsearch/reference/current/… Sep 5, 2019 at 12:39

4 Answers 4

65

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
2
  • you can just use head plugin to see all of these without using curl
    – Emil
    Oct 18, 2018 at 13:30
  • You can use Kibana or curl. Depends upon the use case
    – Ash
    Oct 18, 2018 at 18:04
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
2
  • This is to create and view the content, not to view the index.
    – Ash
    May 29, 2018 at 6:47
  • 2
    This appears to no longer work in Elastic 2.4 and later.
    – clav
    Jun 12, 2018 at 14:33
12

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.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.