Posted on 01/07/2022 10:42:28
With that search and what Lucene (the underlying search engine) can do, I think this is as close as you get.
Your search will technically have 2 terms (because it is analyzed) - the terms are "gulpener" and "pils". Since all your results have both terms, scoring is probably pretty similar on all of them.
Scoring can help you get results higher using boost values, but I do not think it will help in this case because Lucene 3, as we are using, does not take term closeness into account. So what you are seeing here is that "Gulpener Pils 24*30cl krat" is divided into 6 terms in the index - "Gulpener", "pils", "24", "30", "cl", "kraft" and since your search only hit 2 out of 6 terms in that field, scoring is lower than your other products that gets hit in 2 out of 4 terms giving a slightly higher score.
If you really want to go further here, a solution could be one of these:
- Use stopwords to remove terms from being indexed and hence increase scoring in this case - i.e. add "24", "30", "cl" (and maybe "30cl") to the stopwords list. This will improve scoring for products with these kind of terms on them. Caveat is that those terms are not searchable. So be careful. Stopwords here: https://doc.dynamicweb.com/documentation-9/repositories/indexing/custom-fields#4786 - one thing about stopwords is that they are affecting all fields in the index.
- On a product create a custom field for search optimisation - i.e. "product search terms". In that field for this product, add "Gulpener Pils" and leave the remaining terms out of it. On the index, add this field, analyzed with a boost of i.e. 5, and add the field to the query using "Equals" operator on the "q" parameter. This will increase scoring for the product quite a bit and probably fix these things. You might be able to automate this by adding a SQL scheduler that takes the name of the product and remove stuff like numbers and abbrevations like you would do in stopwords.
BR Nicolai