# The test gives different result from the real installation

**URL:** <https://discuss.elastic.co/t/the-test-gives-different-result-from-the-real-installation/113275>\
**Category:** Elasticsearch\
**Created:** [December 27, 2017, 7:42am UTC](https://discuss.elastic.co/t/the-test-gives-different-result-from-the-real-installation/113275 "2017-12-27T07:42:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vgindin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vgindin/32/42012_2.png) [@vgindin](https://discuss.elastic.co/u/vgindin)\
**Post date:** [December 27, 2017, 7:42am UTC](https://discuss.elastic.co/t/the-test-gives-different-result-from-the-real-installation/113275/1 "2017-12-27T07:42:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vgindin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vgindin/32/42012_2.png) [@vgindin](https://discuss.elastic.co/u/vgindin)\
**Post date:** [December 29, 2017, 6:20am UTC](https://discuss.elastic.co/t/the-test-gives-different-result-from-the-real-installation/113275/2 "2017-12-29T06:20:00Z")

</div>

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)

method?

---

<div class="post-metadata">

**Author:** ![Mikhail\_Khludnev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikhail_khludnev/32/59591_2.png) [@Mikhail\_Khludnev](https://discuss.elastic.co/u/Mikhail_Khludnev)\
**Post date:** [December 29, 2017, 6:54am UTC](https://discuss.elastic.co/t/the-test-gives-different-result-from-the-real-installation/113275/3 "2017-12-29T06:54:40Z")

</div>

Hi,

It's hard to follow. Just a note.

> [@vgindin](#):
>
> GET /index/type/342

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

> [@vgindin](#):
>
> explain(id) method takes the wrong ID

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

> [@vgindin](#):
>
> Why? It happens in the real installation, but in the test case - it works fine.

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

---

<div class="post-metadata">

**Author:** ![vgindin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vgindin/32/42012_2.png) [@vgindin](https://discuss.elastic.co/u/vgindin)\
**Post date:** [January 19, 2018, 11:12am UTC](https://discuss.elastic.co/t/the-test-gives-different-result-from-the-real-installation/113275/4 "2018-01-19T11:12:59Z")

</div>

> [@Mikhail\_Khludnev](#):
>
> this number is internal Lucene's id aka docnum which are quite different from external ids.

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?

---

<div class="post-metadata">

**Author:** ![vgindin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vgindin/32/42012_2.png) [@vgindin](https://discuss.elastic.co/u/vgindin)\
**Post date:** [January 19, 2018, 11:55am UTC](https://discuss.elastic.co/t/the-test-gives-different-result-from-the-real-installation/113275/5 "2018-01-19T11:55:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 16, 2018, 11:55am UTC](https://discuss.elastic.co/t/the-test-gives-different-result-from-the-real-installation/113275/6 "2018-02-16T11:55:32Z")

</div>

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