0
votes

When I search say car engine(this is first time any user has searched for this keyword) in Elastic search/lucene , does search engine search the index for individual words in index table first and then find intersection. For example :- Say engine found the 10 documents for car and then it will search for engine say it got 5 documents. Now in 5 documents(minimal no of documents), it will search for car. It has found 2 documents.

Now search engine will rank it based on above results . Is this how multiple words are searched in index table at high level ?

For future searches against same keyword, does search engine make new entry for key car engine in index table ?

1

1 Answers

1
votes

Yes, it does search for individual terms and takes the intersection or union of the results, according to your query. It uses something called an "inverted index" which it generates, as and when the documents to be searched are "indexed" into elasticsearch. Indexing operations are different from searching. So, No, it wouldn't index user searches unless you tell it to (in your application). The basic functioning of elasticsearch can be split into two parts:

  1. Indexing. You create an index of documents by indexing all the documents that you want to search in. These documents could be anything from your MySQL store, or from Logstash etc, or could be made up of users' search queries that your application indexes into a relevant elastic index.
  2. Searching. You search for the indexed documents using some keywords that could be user generated or application generated or a mixture, using ElasticSearch queries (DSL). If a result is found (according to your query) then elasticsearch returns the relevant records.

I'd encourage you to read this doc for a better understanding of how elastic searches docs: https://www.elastic.co/blog/found-elasticsearch-from-the-bottom-up