Hi shay,
Sorry for that i didn't frame my questions correctly.
In order the elaborate the scenario lets say i have an index "index"
with two mappings "mapping1","mapping2" and following are the records
in those;
curl -XPUT 'http://localhost:9200/index/mapping1/1' -d '{
"user" : "kim",
"post" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}'
curl -XPUT 'http://localhost:9200/index/mapping1/2' -d '{
"user" : "ajay",
"post" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}'
curl -XPUT 'http://localhost:9200/index/mapping1/3' -d '{
"user" : "bhavani",
"post" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}'
and if i Search using query
curl "localhost:9200/index/_search?pretty=true" -d '{
"fields" : ["mapping1.user","mapping2.think"],
"query": {
"query_string": {
"query": "kim"
}
}
}'
I am getting following results
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 4,
"max_score" : 0.26516503,
"hits" : [ {
"_index" : "index",
"_type" : "mapping2",
"_id" : "2",
"_score" : 0.26516503,
"fields" : {
"mapping1.user" : null,
"mapping2.think" : "2009-11-15T14:12:12"
}
}, {
"_index" : "index",
"_type" : "mapping2",
"_id" : "3",
"_score" : 0.26516503,
"fields" : {
"mapping1.user" : null,
"mapping2.think" : "2009-11-15T14:12:12"
}
}, {
"_index" : "index",
"_type" : "mapping2",
"_id" : "1",
"_score" : 0.18392482,
"fields" : {
"mapping1.user" : null,
"mapping2.think" : "trying out Elastic Search"
}
}, {
"_index" : "index",
"_type" : "mapping1",
"_id" : "1",
"_score" : 0.13137488,
"fields" : {
"mapping1.user" : "kim",
"mapping2.think" : null
}
} ]
}
}
As you can see in above results i've got 4 results out of which only
one i wanted where "mapping1.user" : "kim" is actually
present.Instead i am receiving all records from mapping2 also where it
doesn't find "user" field and giving me records for "mapping1.user" :
null.
Solution for that can be to use filters while querying.But my mappings
are containing huge number of columns and also in an index there are
considerably large number of mappings present.
So my questions is now;Whatever be the fields i have mentioned in
"fields" array while querying .query_string should only take those
fields and fire on only those records having fields specified in an
array without filters.
Sorry for such long description.I hope it will be helpful in case.
Thanks;
Arien
On Nov 29, 9:36 pm, Shay Banon kim...@gmail.com wrote:
I did not understand the question properly... . You can specify
"field_name", but you can also specify "type1.field_name", which will
automatically wrap the query to be filtered by the type.
On Tue, Nov 29, 2011 at 11:53 AM, arien ajaypa...@gmail.com wrote:
Hi all;
I have some questions when it comes to querying specific fields in
multiple mappings provided that all mappings belongs to same index.say
"test" is the mapping and "testmap1","testmap2","testmap3" are the
mappings of an index.
In query i dont want to specify any mapping name just simply wants to
put searchable columns there.
And the second thing; is it possible to register mapping specific
query against particular index,if so please provide some inputs.
Thanks;
Arien