I would like to get coordinates from my data.
"userLoc" : {
"locNm" : "Alexandra Road",
"coordinates" : [
103.8174926,
1.29143
],
I tried the following to get the second value of coordinates but it didn't work out.
"script": "return _score*doc['userLoc'].coordinates[1];"
Got following error.
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[H94j5eYQRXantctqOKMduw][merchantindex][0]: QueryPhaseExecutionException[[merchantindex][0]: query[function score (_all:test,function=script[return _score*doc['userLoc'].coordinates[1];], params [null])],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[ElasticsearchIllegalArgumentException[No field found for [userLoc] in mapping with types []]]; }{[H94j5eYQRXantctqOKMduw][merchantindex][1]: QueryPhaseExecutionException[[merchantindex][1]: query[function score (_all:test,function=script[return _score*doc['userLoc'].coordinates[1];], params [null])],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[ElasticsearchIllegalArgumentException[No field found for [userLoc] in mapping with types []]]; }{[H94j5eYQRXantctqOKMduw][merchantindex][2]: QueryPhaseExecutionException[[merchantindex][2]: query[function score (_all:test,function=script[return _score*doc['userLoc'].coordinates[1];], params [null])],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[ElasticsearchIllegalArgumentException[No field found for [userLoc] in mapping with types []]]; }{[H94j5eYQRXantctqOKMduw][merchantindex][3]: QueryPhaseExecutionException[[merchantindex][3]: query[function score (_all:test,function=script[return _score*doc['userLoc'].coordinates[1];], params [null])],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[ElasticsearchIllegalArgumentException[No field found for [userLoc] in mapping with types []]]; }{[H94j5eYQRXantctqOKMduw][merchantindex][4]: QueryPhaseExecutionException[[merchantindex][4]: query[function score (_all:test,function=script[return _score*doc['userLoc'].coordinates[1];], params [null])],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[ElasticsearchIllegalArgumentException[No field found for [userLoc] in mapping with types []]]; }]",
"status": 500
}
_source.userLoc.coordinates[0] according to http://grokbase.com/t/gg/elasticsearch/1417z65gy4/using-a-nested-object-property-within-custom-filters-score-script
Related
I am new to elasticsearch and couchbase.I am using both in my project.My requirement is to sync couchbase bucket with elasticsearch indices by using couchbase XDCR.
In couchbase, Bucket name "Employee" and structure of one this document is
{
"empName":"Stev Jobs",
"dept":"IT",
"company":"xxxx",
"salary":"30000",
"country":"USA"
}
I created index in elasticsearch that is employee and also created cluster reference in couchbase with elasticsearch cluster.
After setting all this I started replication between employee bucket of couchbase and employee index of elasticsearch. It created indices in elasticsearch,but this index contains more than couchbase bucket documents.
My couchbase bucket employee has 182 records but in elasticsearch employee index showing docs 1025.
And In couchbase when sync it showing some error s.this error are like below
2015-05-22 09:07:44 [Vb Rep] Error replicating vbucket 98. Please see logs for details.
2015-05-22 09:07:44 [Vb Rep] Error replicating vbucket 697. Please see logs for details.
In elasticsearch my employee index docs structure like
{
"_index": "employee",
"_type": "couchbaseCheckpoint",
"_id": "vbucket921UUID",
"_score": 1,
"_source": {
"doc": {
"uuid": "ec88aeb16c00427698f079d8a3fa7097"
}
}
}
And i write search query like,I run this query in http://127.0.0.1:9200/_plugin/head/
http://127.0.0.1:9200/employee/_search/
{
"query": {
"match":{
"query":"ec88aeb16c00427698f079d8a3fa7097",
"fields":["uuid"]
}
}
}
It giving error
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[J2CjiG2vQqqrG2h5jlsudg][couchrecords][0]: SearchParseException[[couchrecords][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"query":"ec88aeb16c00427698f079d8a3fa7097","fields":["uuid"]}}}]]]; nested: QueryParsingException[[couchrecords] [match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?]; }{[J2CjiG2vQqqrG2h5jlsudg][couchrecords][1]: SearchParseException[[couchrecords][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"query":"ec88aeb16c00427698f079d8a3fa7097","fields":["uuid"]}}}]]]; nested: QueryParsingException[[couchrecords] [match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?]; }{[J2CjiG2vQqqrG2h5jlsudg][couchrecords][2]: SearchParseException[[couchrecords][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"query":"ec88aeb16c00427698f079d8a3fa7097","fields":["uuid"]}}}]]]; nested: QueryParsingException[[couchrecords] [match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?]; }{[J2CjiG2vQqqrG2h5jlsudg][couchrecords][3]: SearchParseException[[couchrecords][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"query":"ec88aeb16c00427698f079d8a3fa7097","fields":["uuid"]}}}]]]; nested: QueryParsingException[[couchrecords] [match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?]; }{[J2CjiG2vQqqrG2h5jlsudg][couchrecords][4]: SearchParseException[[couchrecords][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"query":"ec88aeb16c00427698f079d8a3fa7097","fields":["uuid"]}}}]]]; nested: QueryParsingException[[couchrecords] [match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?]; }]",
"status": 400
}
The couchbaseCheckpoint document is used by the plugin to save state for each vBucket, so that it can emulate the XDCR protocol correctly. That's why there are 1025 of them - 1024 vBuckets plus one global state doc.
The fact that you have 1025 docs in ElasticSearch means that you ONLY got the state docs and none of the actual docs got replicated. Did you set up mappings in ElasticSearch like it says in the installation guide? This looks like a problem with indexing, so the ElasticSearch log will actually have meaningful errors that will tell you why it can't index any of your documents. The Couchbase log only tells you that it couldn't replicate something
I want to use script filter to get all match that the score value equals to maxScore value. but it is not work.
{
"query": {
"filtered": {
"filter": {
"script": {
"script": "doc['match.score'].value == doc['match.maxScore'].value"
}
}
}
}
}
I have this error :
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[yk_PnKg9SOaf1d8acCsjvw][cobink_search][0]: SearchParseException[[cobink_search][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"filter":{"script":{"script":"doc['match.score'].value == doc['match.maxScore'].value"}}}}}]]]; nested: ScriptException[dynamic scripting for [groovy] disabled]; }{[0jYKWZlyQiiVPHlzmoMjkA][cobink_search][1]: RemoteTransportException[[Hammer Harrison][inet[/192.168.1.100:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[cobink_search][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"filter":{"script":{"script":"doc['match.score'].value == doc['match.maxScore'].value"}}}}}]]]; nested: ScriptException[dynamic scripting for [groovy] disabled]; }{[yk_PnKg9SOaf1d8acCsjvw][cobink_search][2]: SearchParseException[[cobink_search][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"filter":{"script":{"script":"doc['match.score'].value == doc['match.maxScore'].value"}}}}}]]]; nested: ScriptException[dynamic scripting for [groovy] disabled]; }{[yk_PnKg9SOaf1d8acCsjvw][cobink_search][3]: SearchParseException[[cobink_search][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"filter":{"script":{"script":"doc['match.score'].value == doc['match.maxScore'].value"}}}}}]]]; nested: ScriptException[dynamic scripting for [groovy] disabled]; }{[0jYKWZlyQiiVPHlzmoMjkA][cobink_search][4]: RemoteTransportException[[Hammer Harrison][inet[/192.168.1.100:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[cobink_search][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"filter":{"script":{"script":"doc['match.score'].value == doc['match.maxScore'].value"}}}}}]]]; nested: ScriptException[dynamic scripting for [groovy] disabled]; }]",
"status": 400
}
Thanks you guys :)
Dynamic scripting is disabled in your case. Add the following line in your elasticsearch.yml file to enable dynamic scripting. Then your query should work. But beware this can leave a security hole in your Elasticsearch cluster. Read more about it here and here.
script.disable_dynamic: false
In version 2.x and above you need to use
script.indexed: on
script.inline: on
in your elasticsearch.yml file, to enable the scripts.
I am new to the ELK stack and have it implemented with elasticsearch version 1.4.4, logstash version 1.4.2, and kibana version 4. I am able to pull a csv file into elasticsearch using logstash and have it display in kibana.
When displaying a date from the file, the values within the date are separated out as if the dash contained within is a separator (ex. value in field is 01-01-2015, when this is displayed in kibana (regardless of display type) there will be three field entries, 01, 01, and 2015). Kibana gives a message that this is due to it being an analyzed field.
Kibana 4 has a feature to use json directly from the dashboard builder, Visualization, to change this to a non-analyzed field so that the entire string will be used, rather than separating it.
I have tried multiple formats, but this is the one that seems it should work as kibana recognizes it as valid syntax:
{ "index" : "not_analyzed" }
but when attempting to apply the change, the dashboard does not change its structure and kibana generates the following exception:
Visualize: Request to Elasticsearch failed: {"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[ftpEMbcOTxu0Tdf0e8i-Ig][csvtest][0]: SearchParseException[[csvtest][0]: query[ConstantScore(BooleanFilter(+cache(#timestamp:[1420092000000 TO 1451627999999])))],from[-1],size[0]: Parse Failure [Failed to parse source [{\"query\":{\"filtered\":{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":{\"bool\":{\"must\":[{\"range\":{\"#timestamp\":{\"gte\":1420092000000,\"lte\":1451627999999}}}],\"must_not\":[]}}}},\"size\":0,\"aggs\":{\"2\":{\"terms\":{\"field\":\"Conn Dt\",\"size\":100,\"order\":{\"1\":\"desc\"},\"index\":\"not_analyzed\"},\"aggs\":{\"1\":{\"cardinality\":{\"field\":\"Area Cd\"}}}}}}]]]; nested: SearchParseException[[csvtest][0]: query[ConstantScore(BooleanFilter(+cache(#timestamp:[1420092000000 TO 1451627999999])))],from[-1],size[0]: Parse Failure [Unknown key for a VALUE_STRING in [2]: [index].]]; }{[ftpEMbcOTxu0Tdf0e8i-Ig][csvtest][1]: SearchParseException[[csvtest][1]: query[ConstantScore(BooleanFilter(+cache(#timestamp:[1420092000000 TO 1451627999999])))],from[-1],size[0]: Parse Failure [Failed to parse source [{\"query\":{\"filtered\":{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":{\"bool\":{\"must\":[{\"range\":{\"#timestamp\":{\"gte\":1420092000000,\"lte\":1451627999999}}}],\"must_not\":[]}}}},\"size\":0,\"aggs\":{\"2\":{\"terms\":{\"field\":\"Conn Dt\",\"size\":100,\"order\":{\"1\":\"desc\"},\"index\":\"not_analyzed\"},\"aggs\":{\"1\":{\"cardinality\":{\"field\":\"Area Cd\"}}}}}}]]]; nested: SearchParseException[[csvtest][1]: query[ConstantScore(BooleanFilter(+cache(#timestamp:[1420092000000 TO 1451627999999])))],from[-1],size[0]: Parse Failure [Unknown key for a VALUE_STRING in [2]: [index].]]; }{[ftpEMbcOTxu0Tdf0e8i-Ig][csvtest][2]: SearchParseException[[csvtest][2]: query[ConstantScore(BooleanFilter(+cache(#timestamp:[1420092000000 TO 1451627999999])))],from[-1],size[0]: Parse Failure [Failed to parse source [{\"query\":{\"filtered\":{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":{\"bool\":{\"must\":[{\"range\":{\"#timestamp\":{\"gte\":1420092000000,\"lte\":1451627999999}}}],\"must_not\":[]}}}},\"size\":0,\"aggs\":{\"2\":{\"terms\":{\"field\":\"Conn Dt\",\"size\":100,\"order\":{\"1\":\"desc\"},\"index\":\"not_analyzed\"},\"aggs\":{\"1\":{\"cardinality\":{\"field\":\"Area Cd\"}}}}}}]]]; nested: SearchParseException[[csvtest][2]: query[ConstantScore(BooleanFilter(+cache(#timestamp:[1420092000000 TO 1451627999999])))],from[-1],size[0]: Parse Failure [Unknown key for a VALUE_STRING in [2]: [index].]]; }{[ftpEMbcOTxu0Tdf0e8i-Ig][csvtest][3]: SearchParseException[[csvtest][3]: query[ConstantScore(BooleanFilter(+cache(#timestamp:[1420092000000 TO 1451627999999])))],from[-1],size[0]: Parse Failure [Failed to parse source [{\"query\":{\"filtered\":{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":{\"bool\":{\"must\":[{\"range\":{\"#timestamp\":{\"gte\":1420092000000,\"lte\":1451627999999}}}],\"must_not\":[]}}}},\"size\":0,\"aggs\":{\"2\":{\"terms\":{\"field\":\"Conn Dt\",\"size\":100,\"order\":{\"1\":\"desc\"},\"index\":\"not_analyzed\"},\"aggs\":{\"1\":{\"cardinality\":{\"field\":\"Area Cd\"}}}}}}]]]; nested: SearchParseException[[csvtest][3]: query[ConstantScore(BooleanFilter(+cache(#timestamp:[1420092000000 TO 1451627999999])))],from[-1],size[0]: Parse Failure [Unknown key for a VALUE_STRING in [2]: [index].]]; }{[ftpEMbcOTxu0Tdf0e8i-Ig][csvtest][4]: SearchParseException[[csvtest][4]: query[ConstantScore(BooleanFilter(+cache(#timestamp:[1420092000000 TO 1451627999999])))],from[-1],size[0]: Parse Failure [Failed to parse source [{\"query\":{\"filtered\":{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":{\"bool\":{\"must\":[{\"range\":{\"#timestamp\":{\"gte\":1420092000000,\"lte\":1451627999999}}}],\"must_not\":[]}}}},\"size\":0,\"aggs\":{\"2\":{\"terms\":{\"field\":\"Conn Dt\",\"size\":100,\"order\":{\"1\":\"desc\"},\"index\":\"not_analyzed\"},\"aggs\":{\"1\":{\"cardinality\":{\"field\":\"Area Cd\"}}}}}}]]]; nested: SearchParseException[[csvtest][4]: query[ConstantScore(BooleanFilter(+cache(#timestamp:[1420092000000 TO 1451627999999])))],from[-1],size[0]: Parse Failure [Unknown key for a VALUE_STRING in [2]: [index].]]; }]"} less
It can be seen within where the index: was changed to not_analyzed from analyzed; also the setting that has wildcard analyzed: true was also changed to false withing the advanced object configuration with the same result.
Try index Mapping and put the date field as non-analyzed.
For Example:
"<index name>": {
"mappings": {
"<Mapping type>": {
"properties": {
"City": {
"type": "string",
"index": "not_analyzed"
},
"Date": {
"type": "string",
"index": "not_analyzed"
}
}
}
I had a similar issue today with the following message:
Parse Failure [Unknown key for a VALUE_STRING in [logTime]: [offset].]]; }]
I was sending a date histogram aggregation request against Elasticsearch 1.4.5 with the following payload:
['logTime'].forEach(function (field) {
body.aggregations[field] = {
date_histogram: {
field: field,
interval: 'week',
time_zone: '+00:00',
offset: '15h',
min_doc_count: 0,
extended_bounds: {
min: 1440946800000,
max: 1441551599999
}
}
};
});
Note the use of offset parameter for the date_histogram. This parameter is introduced in Elasticsearch version 1.5.0 only. So, my 1.4.5 ES was complaining that this offset key was Unknown.
Replacing with post_offset as follows solved the problem though I had to adjust the value of the time_zone parameter as well. As a side note, post_offset is deprecated and replaced with offset since v1.5.
['logTime'].forEach(function (field) {
body.aggregations[field] = {
date_histogram: {
field: field,
interval: 'week',
time_zone: '+09:00',
post_offset: '-9h',
min_doc_count: 0,
extended_bounds: {
min: 1440946800000,
max: 1441551599999
}
}
};
});
I have "organizations" index structure :
{
"organization" : {
"properties" : {
"id" : { "type" : "long" },
"name" : { "type" : "string" }
}
}
}
and another index "campaigns" :
{
"campaign" : {
"properties" : {
"id" : { "type" : "long" },
"name" : { "type" : "string" }
},
"_parent" : {
"type" : "organization"
}
}
}
when i search in campaigns that has specific organization id :
QueryBuilder qb = QueryBuilders.boolQuery()
.must(QueryBuilders.hasParentQuery(SearchEntityEnum.ORGANIZATION.getType(), QueryBuilders.queryString("*" + keyword.replaceAll(" ", "* *") + "*").field(SearchEntityFieldNames.CommonFieldNames.NAME)
.analyzeWildcard(true)));
SearchResponse response = client.prepareSearch(SearchEntityEnum.CAMPAIGN.getIndex())
.setTypes(SearchEntityEnum.CAMPAIGN.getType())
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(qb)
.execute().actionGet();
This error occur :
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query_fetch], all shards failed; shardFailures {[-RCGH_JbTmeTGDSvWp9_wA][campaigns][2]: SearchParseException[[campaigns][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"bool":{"must":{"has_parent":{"query":{"query_string":{"query":"**","fields":["name"],"analyze_wildcard":true}},"parent_type":"organization"}}}}}]]]; nested: QueryParsingException[[campaigns] [has_parent] query configured 'parent_type' [organization] is not a valid type]; }{[-RCGH_JbTmeTGDSvWp9_wA][campaigns][1]: SearchParseException[[campaigns][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"bool":{"must":{"has_parent":{"query":{"query_string":{"query":"**","fields":["name"],"analyze_wildcard":true}},"parent_type":"organization"}}}}}]]]; nested: QueryParsingException[[campaigns] [has_parent] query configured 'parent_type' [organization] is not a valid type]; }{[-RCGH_JbTmeTGDSvWp9_wA][campaigns][4]: SearchParseException[[campaigns][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"bool":{"must":{"has_parent":{"query":{"query_string":{"query":"**","fields":["name"],"analyze_wildcard":true}},"parent_type":"organization"}}}}}]]]; nested: QueryParsingException[[campaigns] [has_parent] query configured 'parent_type' [organization] is not a valid type]; }{[-RCGH_JbTmeTGDSvWp9_wA][campaigns][0]: SearchParseException[[campaigns][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"bool":{"must":{"has_parent":{"query":{"query_string":{"query":"**","fields":["name"],"analyze_wildcard":true}},"parent_type":"organization"}}}}}]]]; nested: QueryParsingException[[campaigns] [has_parent] query configured 'parent_type' [organization] is not a valid type]; }{[-RCGH_JbTmeTGDSvWp9_wA][campaigns][3]: SearchParseException[[campaigns][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"bool":{"must":{"has_parent":{"query":{"query_string":{"query":"**","fields":["name"],"analyze_wildcard":true}},"parent_type":"organization"}}}}}]]]; nested: QueryParsingException[[campaigns] [has_parent] query configured 'parent_type' [organization] is not a valid type]; }
I had the same problem yesterday. I found out that the parent and child types both need to be in the same index in order for the parent to be visible to the child.
In this example, organization and campaign are different types in different indexes. You will need to create one index with both of these types defined within it. Everything else I believe is good here so let me know if you have any further issues.
I believe (might be wrong) that you should define campaigns as a type within organizations index. also you should set routing to true to make this works.
I am new to Elasticsearch and working with a database. I would like to do a query like this:
curl -X GET http://localhost:9200/project/flat_order/_search?pretty=true -d'
{ query:{
bool:{
must:{range:{created_at:{gte:"2012-01-01 00:00:00",lte:"2012-02-01 00:00:00"}}}},
{should:[{term:{status:"canceled"}}],minimum_number_should_match:1}
}
}
}'
and I am getting an error.
"error" : "SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[YfeNrRnOTOqLOtQt65uPVw][project][1]: SearchParseException[[project][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [ { query:{ bool:{ must:{range:{created_at:{gte:\"2012-01-01 00:00:00\",lte:\"2012-02-01 00:00:00\"}}}}, {should:[{term:{status:\"canceled\"}}],minimum_number_should_match:1} } } }]]]; nested: QueryParsingException[[project] Failed to parse]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B#3742925a; line: 1, column: 102]]; }{[YfeNrRnOTOqLOtQt65uPVw][project][2]: SearchParseException[[project][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [ { query:{ bool:{ must:{range:{created_at:{gte:\"2012-01-01 00:00:00\",lte:\"2012-02-01 00:00:00\"}}}}, {should:[{term:{status:\"canceled\"}}],minimum_number_should_match:1} } } }]]]; nested: QueryParsingException[[project] Failed to parse]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B#3742925a; line: 1, column: 102]]; }]",
"status" : 500
}
What to do?
Thanks in advance.
This is the error I am getting without those braces(enclosing should)
"error" : "SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[YfeNrRnOTOqLOtQt65uPVw][project][0]: SearchParseException[[project][0]: query[created_at:[1325376000000 TO 1328054400999]],from[-1],size[-1]: Parse Failure [Failed to parse source [ { query:{ bool:{ must:{range:{created_at:{gte:\"2012-01-01 00:00:00\",lte:\"2012-02-01 00:00:00\"}}}}, should:[{term:{status:\"canceled\"}}],minimum_number_should_match:1 } } }]]]; nested: SearchParseException[[project][0]: query[created_at:[1325376000000 TO 1328054400999]],from[-1],size[-1]: Parse Failure [No parser for element [term]]]; }{[YfeNrRnOTOqLOtQt65uPVw][project][4]: SearchParseException[[project][4]: query[created_at:[1325376000000 TO 1328054400999]],from[-1],size[-1]: Parse Failure [Failed to parse source [ { query:{ bool:{ must:{range:{created_at:{gte:\"2012-01-01 00:00:00\",lte:\"2012-02-01 00:00:00\"}}}}, should:[{term:{status:\"canceled\"}}],minimum_number_should_match:1 } } }]]]; nested: SearchParseException[[project][4]: query[created_at:[1325376000000 TO 1328054400999]],from[-1],size[-1]: Parse Failure [No parser for element [term]]]; }]",
"status" : 500
}
Looking at the error detail, I believe the problem is that you've got an extra level of nesting for your should clause which you shouldn't have. Instead of:
must: { ... },
{ should: { ... },
minimum_number_should_match:1}
}
Try:
must: { ... },
should: { ... },
minimum_number_should_match:1}
EDIT: Your edited code looks like this is your query:
query:{ bool:{ must:{range:{created_at:{gte:\"2012-01-01 00:00:00\",
lte:\"2012-02-01 00:00:00\"}}}}, should:[{term:status:\"canceled\"}}],
minimum_number_should_match:1 }
which, formatted, would be:
query:{
bool:{
must:{
range:{created_at:{gte:\"2012-01-01 00:00:00\",lte:\"2012-02-01 00:00:00\"}}
}
},
should: [
{term:{status:\"canceled\"}}
],
minimum_number_should_match:1
}
... which has the should outside the bool part. In other words, you've got too many closing braces after your must clause. I believe it should be:
query:{
bool:{
must:{
range:{created_at:{gte:\"2012-01-01 00:00:00\",lte:\"2012-02-01 00:00:00\"}}
},
should: [
{term:{status:\"canceled\"}}
],
minimum_number_should_match:1
}
}