Hi,
I am using the Query 2 in my app. The mapping and the query are listed
below:
I am getting more documents that that matches the Query !!
Mapping:
Query
{
"from": 1,
"size": 10,
"query":{
"filtered" :{
"query": {
"bool":{
"must":[
{
"term" : {"notes_emails.reference_type" : "10"
}
}
]
}
},
"filter": {
"term": {
"notes_emails.reference_type": "10"
}
}
}
}
"MyIndexType" :{
"type" : "object",
"properties" : {
"notes_emails":{
"type":"object",
"properties" : {
"_id" : {"type" : "integer", "store":"yes"},
"text" : {"type" : "string", "store":"yes",
"index" : "not_analyzed","term_vector" : "with_positions_offsets"},
"subject" : {"type" : "string", "store":"yes", "index"
: "not_analyzed","term_vector" : "with_positions_offsets"},
"creation_date" : {"type" : "date", "store":"yes",
"index" : "not_analyzed"},
"modification_date" : {"type" : "date", "store":"yes",
"index" : "not_analyzed"},
"created_by" : {"type" : "integer", "store":"yes",
"index" : "not_analyzed"},
"modified_by" : {"type" : "integer", "store":"yes", "index"
: "not_analyzed"},
"activity_type" : {"type" : "string", "store":"yes",
"index" : "not_analyzed"},
"reference_type" : {"type" : "integer", "store":"yes",
"index" : "not_analyzed"},
"type" : {"type" : "string", "store":"yes"}
}
}
}
And here are the results i am getting:
"hits": [
{
"_index": "site462",
"_type": "contact_notes",
"_id": "1340",
"_score": 1,
"_source": {
"notes_emails": {
"_id": 117,
"text": "my test note",
"creation_date": "2012-03-16T09:40:31.725Z",
"modification_date": "2012-03-16T09:40:31.725Z",
"created_by": 342,
"modified_by": 342,
"reference_type": 10,
"type": "ActivityContact"
}
}
},
{
"_index": "site462",
"_type": "contact_notes",
"_id": "1706",
"_score": 1,
"_source": {
"notes_emails": {
"_id": 329,
"text": "another test note",
"creation_date": "2012-07-04T21:57:57.665Z",
"modification_date": "2012-07-04T22:16:18.644Z",
"created_by": 363,
"modified_by": 363,
"reference_type": 10,
"type": "ActivityContact"
}
}
},
{
"_index": "site462",
"_type": "contact_notes",
"_id": "1703",
"_score": 1,
"_source": {
"notes_emails": {
"_id": 37,
"text": "test note",
"creation_date": "2011-12-28T07:29:07.715Z",
"modification_date": "2012-07-03T11:08:53.699Z",
"created_by": 342,
"modified_by": 342,
"reference_type": 70,
"type": "ActivityContact"
}
}
},
{
"_index": "site462",
"_type": "contact_notes",
"_id": "1341",
"_score": 1,
"_source": {
"notes_emails": {
"_id": 26,
"text": "test d",
"creation_date": "2011-12-05T13:21:57.668Z",
"modification_date": "2011-12-05T13:21:57.668Z",
"created_by": 342,
"modified_by": 342,
"type": "ActivityContact"
}
}
}
I am finding it hard to understand why the last two results are returned..
Thanks
On Wednesday, November 14, 2012 5:06:37 AM UTC+5:30, gchen wrote:
Hi,
Apologize in advance if my questions are stupid. I come from SQL
environment. Trying to learning Elastic Search.
-
I read on the Elastic Search site that filters have performance gain
over queries. Then why wouldn't you always use filters then? What are some
sample queries that you can do with queries but not filters? What exactly
is the difference between queries and filters? I tried googling but didn't
find anything. any info or link would be greatly appreciated.
-
I tried playing with queries and filters...The Query 1 works, but Query
2 returned an error. Aren't the two queries functionally equivalent? What
is wrong with the second query?
Query 1:
{
"query":{
"bool":{
"must":[
{"term":{"story_date":20121010}},
{"match":{"_all":"Some Text"}}]
}
},
"from":0,
"size":2
}
Query 2:
{
"filtered" : {
"query" : {
"match":{"_all":"Some Text"}
},
"filter" : {
"term":{"story_date":20121010}
}
},
"from":0,
"size":2
}
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.