Apply scoring after filter

I want the score to be calculated after the filter is applied. Right now, the score gets calculated considering all the documents in the index. And other entity documents interfere with the score calculation which I don't want. eg: I have multiple stores, and each store items should be independently scored.

I tried the score_function, but could not make it work. Indexing items in-store separately can solve the problem, but the store can be in thousands.

Each store can have thousands--200000 documents. Stores can be up to. 10000. can be more, customers can create as many as they want.

    {
      "bool": {
        "should": [{
          "match": {
            "normalized_tokens": {
              "query": "Where can i find the chocolate",
              "analyzer": "custom_analyzed_document_search",
              "operator": "or"
            }
          }
        }, {
          "match": {
            "normalized_tokens": {
              "query": "find chocolate",
              "analyzer": "custom_analyzed_document_search",
              "operator": "or"
            }
          }
        }, {
          "term": {
            "document": "Where can i find the chocolate"
          }
        }],
        "filter": [{
          "bool": {
            "should": [ {
              "terms": {
                "store_id": [1]
              }
            }]
          }
        }]
      }
    }

Else to achieve this I will need to create an index per store for consistent results which seems not to be feasible.

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