Facet query and Exceptions

When testing my query using ES-Head, I receive the following exception
on the server side:

Caused by:
org.elasticsearch.search.facet.FacetPhaseExecutionException: Facet
[range1]: No mapping found for key_field [regularPrice]

Other than indexing the data and forming a query based on:
http://www.elasticsearch.org/guide/reference/api/search/facets/range-facet.html
Are there any other steps involved that I may be missing?

{
"fields": [
"name",
"upc",
"salePrice",
"regularPrice"
],
"query": {
"query_string": {
"fields": [
"name"
],
"query": "+camera +laptop",
"use_dis_max": true
}
},
"facets": {
"range1": {
"range": {
"regularPrice": [
{
"to": 50
},
{
"from": 20,
"to": 70
},
{
"from": 70,
"to": 120
},
{
"from": 150
}
]
}
}
}
}

You are sending the wrong format for the range facet, see the correct structure here: Elasticsearch Platform — Find real-time answers at scale | Elastic.

On Wednesday, March 7, 2012 at 4:45 PM, pulkitsinghal wrote:

{
"fields": [
"name",
"upc",
"salePrice",
"regularPrice"
],
"query": {
"query_string": {
"fields": [
"name"
],
"query": "+camera +laptop",
"use_dis_max": true
}
},
"facets": {
"range1": {
"range": {
"regularPrice": [
{
"to": 50
},
{
"from": 20,
"to": 70
},
{
"from": 70,
"to": 120
},
{
"from": 150
}
]
}
}
}
}

Thanks for the input Shay but as far as I'm aware, the format for the
facets is completely copied pasted out of the link you gave as it was my
starting point. Obviously I'm missing something, can you please elaborate a
bit more?

On Wed, Mar 7, 2012 at 3:08 PM, Shay Banon kimchy@gmail.com wrote:

You are sending the wrong format for the range facet, see the correct
structure here:
Elasticsearch Platform — Find real-time answers at scale | Elastic
.

On Wednesday, March 7, 2012 at 4:45 PM, pulkitsinghal wrote:

{
"fields": [
"name",
"upc",
"salePrice",
"regularPrice"
],
"query": {
"query_string": {
"fields": [
"name"
],
"query": "+camera +laptop",
"use_dis_max": true
}
},
"facets": {
"range1": {
"range": {
"regularPrice": [
{
"to": 50
},
{
"from": 20,
"to": 70
},
{
"from": 70,
"to": 120
},
{
"from": 150
}
]
}
}
}
}

I've found out that the query that I initially posted never had a problem
to begin with, apparently instead of POST-ing directly against
http://localhost:9200/my_index/_search/ I had been posting against
http://localhost:9200/_search/ which was the real source of the exception.

I only have two indices, one is "my_index" and another is the "_river" that
helped put the data in the my_index together. So my guess is that the
exception is really stemming from the _river index which ofcourse does not
have any mapping for the regularPrice field.

What I personally find to be strange is that until I had not run the query
against anything other than http://localhost:9200/_search/ ... there
weren't any results being returned at all. But after I ran the query
against http://localhost:9200/my_index/_search/ just once ... even POST-ing
back again to the original http://localhost:9200/_search/ started providing
results from the my_index and still showing the exception from the _river
index in the logs.

Now if this is a given in terms of normal behavior, then please feel free
to call it out and let me know.

Thanks,

  • Pulkit

On Wed, Mar 7, 2012 at 9:37 PM, Pulkit Singhal pulkitsinghal@gmail.comwrote:

Thanks for the input Shay but as far as I'm aware, the format for the
facets is completely copied pasted out of the link you gave as it was my
starting point. Obviously I'm missing something, can you please elaborate a
bit more?

On Wed, Mar 7, 2012 at 3:08 PM, Shay Banon kimchy@gmail.com wrote:

You are sending the wrong format for the range facet, see the correct
structure here:
Elasticsearch Platform — Find real-time answers at scale | Elastic
.

On Wednesday, March 7, 2012 at 4:45 PM, pulkitsinghal wrote:

{
"fields": [
"name",
"upc",
"salePrice",
"regularPrice"
],
"query": {
"query_string": {
"fields": [
"name"
],
"query": "+camera +laptop",
"use_dis_max": true
}
},
"facets": {
"range1": {
"range": {
"regularPrice": [
{
"to": 50
},
{
"from": 20,
"to": 70
},
{
"from": 70,
"to": 120
},
{
"from": 150
}
]
}
}
}
}