简体   繁体   中英

Elasticsearch document structure for performance optimization

In Elasticsearch is it better to query on 50 fields in 1,000,000 documents or 1 field in 50,000,000 documents. I'll explain my problem with an example:

For case 1, our doc looks like:

doc1: {
    "f1": "abc",
    "f2": "pqr",
    "f3": "lmn",
    ...
    "f50": "xyz"
}

Here a should query will be performed from "f1" to "f50".

For case 2, our doc will look like:

doc1.1: {
    "f": "abc"
}

doc1.2: {
    "f": "pqr"
}    

doc1.3: {
    "f": "lmn"
}
...
...
doc1.50: {
    "f": "xyz"
}

Let's just say I am concerned about the docs containing the queried value irrespective of the field.

I would take the 50 million documents approach. ElasticSearch can handle that size easily with proper hardware (self experience), and it will be much easier for querying and data manipulation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM