# AppSearch Wrong Results From Response

**URL:** <https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787>\
**Category:** Elastic Search\
**Tags:** docker, elastic-app-search\
**Created:** [July 27, 2020, 5:14pm UTC](https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787 "2020-07-27T17:14:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![corvallo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corvallo/32/57044_2.png) [@corvallo](https://discuss.elastic.co/u/corvallo)\
**Post date:** [July 27, 2020, 5:14pm UTC](https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787/1 "2020-07-27T17:14:24Z")

</div>

Hi everyone, I'm quite new to the Elasticsearch world. I managed to configure Elastic Search Stack to run on docker, version 7.6.0 . I use AppSearch and I'm facing a strange behavior when I receive results. I've some documents on the engine. When this query

```auto
   {
  "query": "bas",
  "page": {
    "current": 1,
    "size": 10
  },
  "result_fields": {
    "localita": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "associazione_sportiva_dilettantistica": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "tipo": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "ente_promozione_sportiva": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "cognome": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "corso": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "indirizzo": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "created_at": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "id": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "limite_partecipanti": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "provincia": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "regione": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "codice_fiscale": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "updated_at": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "comitato": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "host": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "max_partecipanti": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "descrizione_breve": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "fax": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "telefono": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "slug": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "email": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "partita_iva": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "citta": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "nome_abbreviato": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "manager": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "internal_id": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "socio": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "costo": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "min_partecipanti": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "durata": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "nome": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "message": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "tags": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "durata_attivita": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "descrizione": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "port": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "sito_web": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "immagine": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "manager_asd": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "user": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    },
    "username": {
      "raw": {},
      "snippet": {
        "size": 100,
        "fallback": true
      }
    }
  }
}

```

I receive just 1 result (as I expect), but when i try to add a letter into the query I received 3 results but two of them doesn't have anything that is in the query field.  
Am I doing something wrong?

Thanks in advance to everyone.

**EDIT**

I've tested this also on a new engine with 1 document only, for this test I've used version 7.8.0 of Elasticsearch and moved everything under Enterprise Search. I've used this document for the test

```auto
{
  "tipo": "corso",
  "internal_id": 2,
  "nome": "Corso Windsurf",
  "durata": "1 mese",
  "descrizione": "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur? At vero eos et accusamus et iusto odio dignissimos ducimus, qui blanditiis praesentium voluptatum deleniti atque corrupti, quos dolores et quas molestias excepturi sint, obcaecati cupiditate non provident, similique sunt in culpa, qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio, cumque nihil impedit, quo minus id, quod maxime placeat, facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet, ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.",
  "descrizione_breve": "Corso Windsurf",
  "regione": "Puglia",
  "provincia": "Lecce",
  "citta": "Lecce",
  "slug": "corso-windsurf",
  "costo": "100",
  "max_partecipanti": null,
  "associazione_sportiva_dilettantistica": "1",
  "immagine": "/uploads/windsurf_a8896e8fb7.jpeg",
  "tags": [
    "Mare",
    "windsurf"
  ],
  "id": "corso_2"
}

```

With query tester I searched for "bas", and as I expected I received 0 results  
then I tested again with this word "basi", but in this case i received 1 result.  
Then I removed the document from engine and re-added it but without the "descrizione" field.  
I re-launched query tester with both the previous queries and in both response I received 0 results.  
So I'm wondering if the problem is a long text in the document that could cause this strange behaviour.

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [July 28, 2020, 11:52am UTC](https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787/2 "2020-07-28T11:52:30Z")

</div>

So you seeing results that you don't believe should match your query?

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [July 28, 2020, 12:08pm UTC](https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787/3 "2020-07-28T12:08:00Z")

</div>

App Search favors recall over precision in queries. In other words, we do very aggressive matching which results in a large result set, but we have an advanced relevance system that ensures that the most relevant results are always shown first.

It's totally normal to see documents in your results where it's not immediately apparent why it's a match.

---

<div class="post-metadata">

**Author:** ![corvallo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corvallo/32/57044_2.png) [@corvallo](https://discuss.elastic.co/u/corvallo)\
**Post date:** [July 28, 2020, 12:09pm UTC](https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787/4 "2020-07-28T12:09:01Z")

</div>

> [@JasonStoltz](#):
>
> other

Yeah exactly.

> It's totally normal to see documents in your results where it's not immediately apparent why it's a match.

The fact is the there's nothing that should match that query. Considering your answer, I still can't understand why with this query "bas" i have 1 result and with this query "basi" I get 3 results. If it's all about relevance I should have 3 results also in first case? Is my thinking right?

---

<div class="post-metadata">

**Author:** ![corvallo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corvallo/32/57044_2.png) [@corvallo](https://discuss.elastic.co/u/corvallo)\
**Post date:** [July 28, 2020, 12:17pm UTC](https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787/5 "2020-07-28T12:17:03Z")

</div>

BTW I also tried reducing the size of the field "descrizione" to 500 chars. With resizing, results returns as I expected.

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [July 28, 2020, 12:36pm UTC](https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787/6 "2020-07-28T12:36:04Z")

</div>

> The fact is the there's nothing that should match that query.

The value of "descrizione" is as follows.

> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur? At vero eos et accusamus et iusto odio dignissimos ducimus, qui blanditiis praesentium voluptatum deleniti atque corrupti, quos dolores et quas molestias excepturi sint, obcaecati cupiditate non provident, similique sunt in culpa, qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio, cumque nihil impedit, quo minus id, quod maxime placeat, facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet, ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

If you are searching for the text "basi", "basi" is compared against each word in that field individually looking for a match. There is a high likelyhood that in a field with that many words that one of them will match. Remember, it's a very aggressive search, so it doesn't have to be an exact match, it could be a "fuzzy" match where 3 of the 4 characters match, for instance.

If you don't want to match on the "descrizione" field, you can change which fields are searchable in the "Relevance Tuning" section of the Dashboard, or programatically in your search calls [Search API search fields | App Search documentation [8.11] | Elastic](https://www.elastic.co/guide/en/app-search/current/search-fields-weights.html)

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [July 28, 2020, 12:40pm UTC](https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787/7 "2020-07-28T12:40:41Z")

</div>

> [@corvallo](#):
>
> If it's all about relevance I should have 3 results also in first case? Is my thinking right?

Nope, that's not how it works. There's certain types of matching that may not be enabled unless you're searching for a minimum number of characters, for instance. Like prefix matching. If we tried to do prefix matching when all you've searched for is "b", you will get way too many results.

---

<div class="post-metadata">

**Author:** ![corvallo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corvallo/32/57044_2.png) [@corvallo](https://discuss.elastic.co/u/corvallo)\
**Post date:** [July 28, 2020, 12:53pm UTC](https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787/8 "2020-07-28T12:53:32Z")

</div>

Ok thanks for your explanation. Now it's more clear. I guess I'll try with the "relevance tuning" approach.  
Again, thanks

---

<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:** [August 25, 2020, 12:53pm UTC](https://discuss.elastic.co/t/appsearch-wrong-results-from-response/242787/9 "2020-08-25T12:53:34Z")

</div>

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