Problem creating percolator - No field mapping can be found for the field with name


(Ryan Ramage) #1

I am having a problem creating a percolator. I feel that I am doing everything according to the docs, so help would be appreciated.

The root of my issue is I cant create a percolator document. The put is like this:

 git:(master) 3M ®[assets]$ http PUT http://elastic-1:9200/idx-edm-v5/.percolator/2 < sample_percolate.json
HTTP/1.1 500 Internal Server Error
Content-Length: 221
Content-Type: application/json; charset=UTF-8

{
    "error": "PercolatorException[[idx-edm-v5] failed to parse query [2]]; nested: QueryParsingException[[idx-edm-v5] Strict field resolution and no field mapping can be found for the field with name [price]]; ",
    "status": 500
}

Where sample_percolate.json looks like:

{
  "type": "saved-search",
  "account": "01P_KBhB4UMnjZLSjhV4NG--/forms~rwp-1839",
  "query": {
    "filtered": {
      "query": [
        {
          "match_all": {}
        }
      ],
      "filter": {
        "and": [
          {
            "range": {
              "price": {
                "gte": 100000
              }
            }
          },
          {
            "range": {
              "price": {
                "lte": 150000
              }
            }
          }
        ]
      }
    }
  }
}

I use this exact query in the _search endpoint and it works fine, so I am trying to use the same format for the percolate.

I already have a mapping defined, which is quite large, but here I show that the index has a mapping called listing, with a field called price, which is a long

git:(master) 4M ®[assets]$ http GET http://elastic-1:9200/idx-edm-v5/_mapping/listing/field/price
HTTP/1.1 200 OK
Content-Length: 107
Content-Type: application/json; charset=UTF-8

{
    "idx-edm-v5": {
        "mappings": {
            "listing": {
                "price": {
                    "full_name": "price",
                    "mapping": {
                        "price": {
                            "type": "long"
                        }
                    }
                }
            }
        }
    }
}

My version of elasticsearch

{
  "status" : 200,
  "name" : "Raving Beauty",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.5.0",
    "build_hash" : "544816042d40151d3ce4ba4f95399d7860dc2e92",
    "build_timestamp" : "2015-03-23T14:30:58Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.4"
  },
  "tagline" : "You Know, for Search"
}

Can someone help me understand what I am doing wrong?


(Martijn Van Groningen) #2

In sample_percolate.json you're referring to the type saved-search does this type have a price field?

The type field in a percolator query document tells ES what mapping to use when parsing the query:
https://www.elastic.co/guide/en/elasticsearch/reference/1.5/search-percolate.html#_indexing_percolator_queries


(Ryan Ramage) #3

Wow that was it. Renaming the property name from 'type' to 'search-type' fixed it. I did not realize from the percolate docs that the 'type' property had semantic meaning.

Thanks!


(system) #4