Staging deployments with GIT
Door Gert-Jan van de Streek / jan 2012 / 1 Min
Door Gert-Jan van de Streek / / 1 min
I figured out how to search parts of words with elasticsearch. If you are not familiar with the terms used in the documentation this can be quite a challenge. I will show you the key parts of the configuration you need.
First, you need to know a little about the search engine. When you store documents, the text is indexed. This is done by tokenizing the text, basically chopping it up and then running those chops through one or more filters. When searching the same happens to the search terms (chop / filter / used for search).
The tokenization and filtering for indexing and searching can be configured independently. Most of the time these configurations are to be kept the same, as illustrated by this case that uses a lowercase filter:
If you search for this text (using the lowercase filter again):
Notice that both the indexed text and the search term are lowercase and will thus match. If you would not configure a lowercase search filter this would not return a result.
In the case where you want to search for parts of words however, the filters used for index time differ from the filters used for search. Here is the elasticsearch configuration for creating an index, that defines the filters to be used for indexing and for searching:
The numbers correspond to the critical parts of the configuration (explained below).
| Software Development
Door Gert-Jan van de Streek / okt 2024
Dan denken we dat dit ook wat voor jou is.