What index(actual lucene inverted index) does a query request hit?

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:

  1. Query1:
{
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "filter": [
              {
                "term": {
                  "id": {
                    "value": "id1"
                  }
                }
              }
            ]
          }
        },
        {
          "bool": {
            "filter": [
              {
                "term": {
                  "fName": {
                    "value": "John"
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}
  1. Query2:
{
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "filter": [
              {
                "term": {
                  "id": {
                    "value": "id1"
                  }
                }
              }
            ]
          }
        },
        {
          "bool": {
            "match": [
              {
                "aboutMe": {
                  "query": "unknown"
                }
              }
            ]
          }
        }
      ]
    }
  }
}
  1. While indexing, what all inverted indexes are created?
  2. Does ES create inverted indexes for a keyword type mapping fields?
  3. 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?
  4. 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
  5. 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

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.