Error searching with double quotes: IllegalStateException[field "title" was indexed without position data; cannot run PhraseQuery


(Marlon Hizole) #1

Hi,

I'm quite new to Elasticsearch. I'm trying to do an "exact match" search using double quotes and based on this article it is possible: http://www.elastic.co/guide/en/elasticsearch/reference/1.x/query-dsl-query-string-query.html

However, I always get this error: IllegalStateException[field "title" was indexed without position data; cannot run PhraseQuery. It works fine with single quotes, but not double quotes.

How do I solve this issue?

Thanks!


(David Pilato) #2

What does your mapping look like?


(Marlon Hizole) #3

It has a MultiField mapping:

{
  "assets" : {
    "mappings" : {
      "asset" : {
        "properties" : {
          "assetReference" : {
            "type" : "string",
            "fields" : {
              "assetReference.raw" : {
                "type" : "string",
                "index" : "not_analyzed"
              }
            }
          },
          "id" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "location" : {
            "type" : "geo_point"
          },
          "modified" : {
            "type" : "date",
            "format" : "dateOptionalTime"
          },
          "modifiedBy" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "title" : {
            "type" : "string",
            "fields" : {
              "title.raw" : {
                "type" : "string",
                "index" : "not_analyzed"
              }
            }
          }
        }
      }
    }
  }
}

I also tried without MultiFields, but I'm still getting the same error.


(David Pilato) #4

Is this the output of GET /index/type/_mapping?

If so, any chance you could reproduce this using a script?


(Marlon Hizole) #5

Yes, that's the output of the _mapping endpoint. Sorry, I'm not exactly sure what type of script you are looking for. And, I'm not sure how to convert that into a script. Is there a different information I can give you?


(David Pilato) #6

Something we can reproduce easily. Like:

DELETE index
PUT index/type/1
{
  "foo": "bar"
}
GET index/type/_search
{
  "query": {
    "match": {
      "foo": "bar"
    }
  }
}

(system) #7