Reputation: 5880
We know that in ElasticSearch there are Index and doc Type, the query url look like: 192.168.0.10:/index/type. My question is that what can we do by using type, I was thinking can I use another index directly. What's the benefit if I use type instead of a new index? For example, If I wanna create two indices as book and goods. I can create two index such as: /book /goods, also I can create one index with two types: /myindex/book, /myindex/goods.
Upvotes: 0
Views: 251
Reputation: 52368
Lucene doesn't know about document types, only Elasticsearch uses this. The type name of each document is stored with the document in a metadata field called _type
. When we search for documents of a particular type, Elasticsearch simply uses a filter on the _type
field to restrict results to documents of that type.
So, types are just a logical representation and a quick of filtering documents. The types belonging to the same index reach the same index and a shard can contain documents from multiple types.
If you use a separate index, instead of separate types your node will hold multiple, smaller shards. The number of shards in a node matters because the resources of the node (memory, CPU, IOPS) are shared between the shards.
Upvotes: 2