Discussion on: Elasticsearch is different

akamanzi profile image
Arnold Kamanzi

Thanks Chris for the insights on Elastic search, i just had a quick question though, if i wanted to build a search engine, what role would elastic search play or how can i leverage it. Thanks in advance

chrishunt profile image
Chris Hunt Author

Hi. Elasticsearch is where the index resides for your data. This index makes your data searchable in ways not possible by databases. It's unlikely to be your main document store (although, I suspect many projects do use it as such) and you would populate your index from that. It's highly likely that your search index would be a different structure to your data store so it would likely to go through some level of transformation on the way in.

I appreciate there seems a lot of uncertainty in the previous paragraph but most of it depends on your search requirements.

I'll run through the basic steps to set up an index which may assist with some understanding.

You would design your mappings dependant on how you want your search engine used and how you want the data indexed (to allow for efficient searches). An overview of designing mappings is available on the ES website - elastic.co/guide/en/elasticsearch/...

Part of the mapping, you would look to analyze and tokenize certain fields. This is the process of indexing parts of the field, maybe down to the individual word, phrase or part phrase - tokens.

Once your mapping is set up, you can start populating your index. This is done simply by HTTP request.

Then you can start building your search queries. Basic queries via DSL (elastic.co/guide/en/elasticsearch/...) are quite simple.

At this point, I find it's time for a bit of educated trial and error. Is your search query finding expected results? If not, why not? Tweak query to better score expected results, bearing in mind that tweaking query to affect the result of this document may affect the result of others.

This may appear daunting but the Getting Started guide on ES site is pretty good - elastic.co/guide/en/elasticsearch/...