2021年3月5日星期五

Synonyms, Product Names, and Shingles

I am building a product search feature for a mobile app using AWS Elasticsearch Service. I have run into an issue that I would like to solve by tuning ES rather than pre-processing the query. Here is an example:

Product User Wants: mini farfalle pasta    User's Query: mini bow-tie pasta    What Works: mini AND (bow-tie OR bow tie OR bowtie OR farfalle) AND pasta  

I have tried building the index using shingles. Doing this places the following in the index:

mini, mini farfalle, mini farfalle pasta, farfalle, farfalle pasta, pasta  

My next thought was to create a synonym graph like this:

bow tie, bowtie, farfalle  

However, when I ran analyze it looked as though ES simply took "bow-tie" and replaced it with "bow-tie bow tie bowtie farfalle" in the user's query, essentially turning the query into:

mini bow-tie bow tie bowtie farfalle pasta  

When I turn the new query into search terms that are built as shingles (to match my index) I get the following:

mini, mini bowtie, mini bowtie farfalle, bowtie, bowtie farfalle, bowtie farfalle bow, farfalle, farfalle bow, farfalle bow tie, bow, bow tie, bow tie pasta, tie, tie pasta, pasta  

None of which will return the product I am searching for.

What I really need ES to do is SUBSTITUTE the synonyms to build singles like:

mini, mini bow-tie, mini bow-tie pasta, bow-tie, bow-tie pasta, pasta  mini, mini bow, mini bow tie, bow, bow tie, bow tie pasta, tie, tie pasta, pasta  mini, mini bowtie, mini bowtie pasta, bowtie, bowtie pasta, pasta  mini, mini farfalle, mini farfalle pasta, farfalle, farfalle pasta, pasta  

Since I am new to ES I suspect I am missing something simple that will fix this.

https://stackoverflow.com/questions/66409836/synonyms-product-names-and-shingles February 28, 2021 at 09:57PM

没有评论:

发表评论