curl -X PUT "localhost:9200/mytest/abc/_mapping" -d '{
"abc" : {
"_routing" : {
"required" : true
}
"properties" : {
"idx" : {"type" : "string", "index" : "not_analyzed"},
"a" : {"type" : "string"},
"b" : {"type" : "string"},
"c" : {"type" : "integer"},
"txt" : {"type" : "string", "null_value" : "na"}
}
}
}
Lots of abc documents indexed into mytest index - a.o. this
curl -XPUT
"localhost:9200/mytest/abc/1234_5678_90123?routing=1234_5678_90123" -d '{
"sms" :
{
"a" : "1234",
"b" : "5678",
"c" : 90123,
"txt" : "Hello World"
}
}
Expect this "get" will be very efficient:
curl -XGET
"http://localhost:9200/mytest/abc/1234_5678_90123?routing=1234_5678_90123"
I have cheated a little in the code above, when I indicate that I can
make an id consisting of the values of a, b and c. It is only almost
true - sometimes (but very very seldom) there will be documents with the
same values for a, b and c. Therefore I cannot make id's like this (will
have to make a_b_c_X id's og just GUID id's instead), and therefore I
cannot "find" the document(s) using the "get" above.
Question: If I know that there will never be more than a few documents
with concrete values for a, b and c, can I create a "search" finding
those documents, a search that is just (or almost) as efficient (with
respect to searchtime and resources used) as the "get" above? Note that
I am using routing so I should at least be able to hit the right shard
in such a search.
In a RDMS I would make an combined index of a, b and c and use the query
"select * from abc where a="1234" and b="5678" and c=90123" (the
"search") instead of "select * from abc where id="1234_5678_90123"" (the
"get"), and that would be just as efficient (if the RDMS uses the
combined index, or else I will force it by hinting).
Thanks!
Regards, Per Steffensen