Hi,
I have only one document type (only one mapping).
The documents are grouped, for example, by zip code.
And our searches are always bound within a group, for example only for 94040.
We do not search on multiple groups.
In this situation, which design is better?:
have the zip code as a type, so that we can search only for that zip code by issueing search query
"http://localhost:9200//94040/_search" ...
have the zip code as a field, then filter by the field
"http://localhost:9200///_search" -d '{
"query":{"filtered":{"query":{..},"filter":{"term":{"zip":94040}}}}}'
I do not think there is a difference in performance. Mappings are
defined by type, so it would be easier to maintain a mapping against a
fixed type and not need a dynamic mapping across all types in an
index, IMHO.
Hi,
I have only one document type (only one mapping).
The documents are grouped, for example, by zip code.
And our searches are always bound within a group, for example only for
94040.
We do not search on multiple groups.
In this situation, which design is better?:
have the zip code as a type, so that we can search only for that zip code
by issueing search query
"http://localhost:9200//94040/_search" ...
have the zip code as a field, then filter by the field
"http://localhost:9200///_search" -d '{
"query":{"filtered":{"query":{..},"filter":{"term":{"zip":94040}}}}}'
There isn't a difference in terms of perf or disk store, a type is actually
stored as another field in a doc. You will create multiple mappings in this
case for each zip, which is a waste in terms of storing the cluster state.
So, use a field and filter by it.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.