Hi,
I want to understand how a query is executed and what all lucene indexes does it hit to find a match?
Lets say I have a document like:
{
"id":"id_1",
"fName":"John",
"lName":"DOe",
"age":28,
"email":"johndoe@exmple.com",
"aboutMe":"A fictitious name used to identify an unknown man or body. Also referred to as 'Jane Doe'."
}
an index mapping like:
"person-index": {
"mappings": {
"person": {
"dynamic": "false",
"properties": {
"id": {
"type": "keyword"
},
"fName": {
"type": "keyword"
},
"lName": {
"type": "keyword"
},
"age": {
"type": "long"
},
"email": {
"type": "keyword"
},
"aboutMe": {
"type": "text"
}
}
}
}
}
My query is like:
- Query1:
{
"query": {
"bool": {
"filter": [
{
"bool": {
"filter": [
{
"term": {
"id": {
"value": "id1"
}
}
}
]
}
},
{
"bool": {
"filter": [
{
"term": {
"fName": {
"value": "John"
}
}
}
]
}
}
]
}
}
}
- Query2:
{
"query": {
"bool": {
"filter": [
{
"bool": {
"filter": [
{
"term": {
"id": {
"value": "id1"
}
}
}
]
}
},
{
"bool": {
"match": [
{
"aboutMe": {
"query": "unknown"
}
}
]
}
}
]
}
}
}
- While indexing, what all inverted indexes are created?
- Does ES create inverted indexes for a
keyword
type mapping fields? - When the query is passed to a particular shard, which inverted indexes are hit?
3.1 Are all of the (lucene)indexes in query hit?
3.2 How does elasticsearch decide in what order are these indexes hit? - If looking at similar document indexing in a Document database like MongoDb, we would end up creating a specific index. What kind of algorithm do databases like mongoDB in general use to select a particular index to fulfill a query
- How is the algorithm in case of elasticsearch to find a index to hit different in case of elastic-search than other databases, say MongoDb?
Thanks