0

I'm using ElasticSearch 2.3.3.

I have the following mapping:

"mappings": {
    "entries": {
        "dynamic": "strict",
        "properties": {
            "Data": {
                "properties": {
                    "FirstName": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
                }
            }
        }
    }
}

I have the following query:

POST /frm4356/entries/_search
{
    "query" : {
        "match" : {"Data.FirstName" : "BBB"}
    }
}

Which works fine and yields the following response:

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "frm4356_v3",
        "_type": "entries",
        "_id": "57c867715f7ecd2a78610ec6",
        "_score": 1,
        "_source": {
          "Data": {
            "FirstName": "BBB"
          }
        }
      }
    ]
  }
}

I tried to used the "Explain API" but failed miserably.

The following did not work:

Attempt #1

POST /frm4356/entries/_explain
{
    "query" : {
    "match" : {"Data.FirstName" : "BBB"}
    }
}

Attempt #2:

POST /frm4356/entries/_search
{
    "explain" : true,
    "query" : {
    "match" : {"Data.FirstName" : "BBB"}
    }
}

In both cases, I keep getting this response:

{
   "error": {
      "root_cause": [
         {
            "type": "strict_dynamic_mapping_exception",
            "reason": "mapping set to strict, dynamic introduction of [query] within [entries] is not allowed"
         }
      ],
      "type": "strict_dynamic_mapping_exception",
      "reason": "mapping set to strict, dynamic introduction of [query] within [entries] is not allowed"
   },
   "status": 400
}

What am I doing wrong ? I'd like to see the explanation of the query.

2 Answers 2

2

Try something like this:

GET /blog/post/_validate/query?explain
{
  "query": {
    "match": {
      "title": "Smith"
    }
  }
}

Source

Sign up to request clarification or add additional context in comments.

Comments

0

Here's the official documentation for Explain API.

It looks like you missed the _id there.

POST /frm4356/entries/57c867715f7ecd2a78610ec6/_explain
{
  "query": {
    "match": {
      "Data.FirstName": "BBB"
    }
  }
}

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.