Apply Fuzzy Search and Searching-with-without-spaces

I am using Elasticsearch 7.4 and Spring boot 2.3.1 (Spring JPA Elasticsearch) would like to get the same results if the words have space or without space and would like to perform fuzzy search also for the same property.

Example: Some of the documents have a company name as Nike and some documents have the company name as Orbital Sciences or AirBus.

Expected Result:

  • Even if the user searches the: OrbitalSciences; he should get the result as Orbital Sciences.
  • If the user searches Air Bus he should get the result as AirBus.
  • And finally if the user searches the: Mike or ike he should get the result as Nike.

I am able to get a fuzzy search working without applying the custom space analyzer; yes I do know that for searching with and without space, we have to create a custom analyzer. But as when I am applying custom analyzer with and without space search on the document for the company name property the fuzzy search stops working for company name because in background index is created as per the custom analyzer.

I am new to Elasticsearch; so my question is how can we apply Fuzzy and with-without-spaces searching on the same property for a document.

Thank you.

Take a look at the word delimeter token filter

@spinscale Thanks for the reply.

As you suggested I have applied the word delimiter graph and its working as expected.

As I am using Spring boot + Elasticsearch so I applied the below custom analyser to my document class and set the analyzer to the particular column.

This is how my custom analyser JSON look like:
{
"index": {
"analysis": {
"analyzer": {
"word_join_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"word_delimiter_graph",
"custom_shingle",
"my_char_filter"
]
}
},
"filter": {
"custom_shingle": {
"type": "shingle",
"min_shingle_size": 2,
"max_shingle_size": 3,
"output_unigrams": true
},
"my_char_filter": {
"type": "pattern_replace",
"pattern": " ",
"replacement": ""
}
}
}
}
}

Tested with fuzzy search and searched document with and without space it all worked as expected; can you please suggest am I missing something or is there any other better approach. Thanks.

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