ElasticSearch - Search issues

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
kdim95
Advanced
Posts: 205
Joined: 26 Aug 2022, 12:17

ElasticSearch - Search issues

Post by kdim95 » 16 Aug 2023, 10:03

Laravel framework version: 10.16.1
Aimeos Laravel version: 2023.04.*
PHP Version: 8.2.8
Environment: Linux

Hello,

I am experiencing the following issue:

I have added a custom attribute to individual products (seen).
The "seen" attribute represents how many times a product's detail page has been viewed.
The problem is that if the value of "seen" changes, the "_score" of the search changes.
Even though I'm not taking the product's "seen" value while searching, but just the product code.
Therefore the position of the product in the product listing randomly changes when a product's details page has been viewed.
I am ordering the products by their names in the product listing.
I think that it's the "_score" that's causing this, but not exactly certain, what exactly is causing the "_score" to change when I'm not even including "seen" as a search parameter in elastic?

I've made a custom query to test the search:

Code: Select all

curl -X POST "localhost:9200/my_index/_search?pretty" -H 'Content-Type: application/json' -d '{
    "query": {
        "term": {
            "base.product.code": "<PRODUCT CODE>"
        }
    }
}'

User avatar
aimeos
Administrator
Posts: 7894
Joined: 01 Jan 1970, 00:00

Re: ElasticSearch - Search issues

Post by aimeos » 23 Aug 2023, 07:24

The score is calculated by Elasticsearch internally and you can influence calculation but I don't know if you can avoid a changed score when a document field is updated.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kdim95
Advanced
Posts: 205
Joined: 26 Aug 2022, 12:17

Re: ElasticSearch - Search issues

Post by kdim95 » 25 Aug 2023, 14:27

Ok, the problem is not the score, but the max_result_window, it sorts only the first 10,000 products and some of them remain out of range and not sorted.
There are more than 100,000 products in the index, which need to be sorted.
I know that increasing the max_result_window would impact performance, so I would like to avoid that.
How can I solve this problem?

User avatar
aimeos
Administrator
Posts: 7894
Joined: 01 Jan 1970, 00:00

Re: ElasticSearch - Search issues

Post by aimeos » 29 Aug 2023, 11:28

This is a question you should ask in the ElasticSearch discussion forum. Maybe you get an answer there.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply