The test gives different result from the real installation

(Vadim Gindin) #1

Hi all.

I've written a simple plugin, that implements custom scoring logic and extending Explanation. I have some real index data that looks like this:

"_source": {
      "price": 10000,
      "params_model": "Дверь задняя правая Honda CR-V",
      "categories": [
          "id": 3,
          "shop_category_id": "3",
          "name": "Кузов наружные элементы",
          "level": 1
          "id": 342,
          "shop_category_id": "62",
          "name": "Дверь задняя правая",
          "level": 2
      "params_vendor": "Honda",

My plugin remembers the document id (that was matched in scorer) to a collection. When explain(id) is called it checks specified id in this collection and outputs "matched"/"not matched".

The questions.
0. This document is founded by the plugin, but explain(id) method takes the wrong ID. Why? It happens in the real installation, but in the test case - it works fine.

  1. ID=342 and others come to explain(id) method. Note, it is not a document id - it is ID of the nested object (category). Why it happens?
  2. I have a test case, based on ESIntegTestCase. It works fine with this document. But this document is not founded in the real index.

How to specify the index mapping in ESIntegTestCase?
(Vadim Gindin) #2

If I check

GET /index/type/342

Nothing is found. It is correct because one Category is not a separate document. It is only a nested object. But why its property "id" comes to

Weight.explain(LeafReaderContext context, int doc)


(Mikhail Khludnev) #3


It's hard to follow. Just a note.

Should work for meta field _id. Not for user's ones.

this number is internal Lucene's id aka docnum which are quite different from external ids.

This often happens when segment's docbase is left. Try to flush() in the middle of indexing docs to reproduce index segmentation.

(Vadim Gindin) #4

Is there a way to get an external document ID in explain() method using specified internal ID?

Once again. The ID from the query "GET some_idx/test/31" is an external ID, and ID that comes as a parameter of explain() method - is internal ID. Right?

(Vadim Gindin) #5

Assume, I have some scorer. During the execution of score() method, I'm caching a document id and scoring details to a Map. Further, in the explain(docID) method, I'm taking scoring details from that map by docID. Is it a correct scheme? If no how to implement it correctly?

(system) #6

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