Natural language processing in vespa.ai

Viewed 80

{ "yql": "select * from sources post where text contains \"brandmüller\";", "locale": "en" }

The query does not yield the expected results. If I change the query from brandmüller to Brandmüller (titlecase) or locale to de, everything works.

Admittedly, this feature is clever, because Brandmüller is right. But for some reasons I would prefer to simply ignore the case. Is there an option to disable the uppercase/lowercase feature in the query api?

3 Answers

See https://docs.vespa.ai/documentation/linguistics.html - this is most likely a feature of normalization

It is useful to add &tracelevel=5 to the query (some number, in/decrease as needed) to see the effect of query processing

most often, leaving default processing on is what you want (i.e. lowercase). It is possible to exclude searchers in the query processing chain, though, easier to discuss once you have the processing trace

https://docs.vespa.ai/documentation/text-matching-ranking.html#match-configuration-debug is useful, and see vespa-index-inspect / vespa-attribute-inspect in the same document for how to see how the terms are indexed

You can inspect the query handling, parsing, stemming etc by adding tracelevel=3

E.g

https://api.cord19.vespa.ai/search/?query=Brandm%C3%BCller&tracelevel=3

Stemming: [select * from sources * where default contains ([{"origin": {"original": "Brandm\u00FCller", "offset": 0, "length": 11}, "stem": false}]"brandm\u00FCller") timeout 1999;]

https://api.cord19.vespa.ai/search/?query=Brandm%C3%BCller&tracelevel=3&language=de

"Stemming: [select * from sources * where default contains ([{"origin": {"original": "Brandm\u00FCller", "offset": 0, "length": 11}, "stem": false}]"brandmull") timeout 1997;]" },

There should be no difference in case, but stemming depends on the language, e.g brandmüller will be stemmed to brandmull for both brandmüller and Brandmüller.

Matching in Vespa is case-insensitive, but stemming and normalization is not (in general).

I guess the data here is indexed with locale "de", and when you query with locale "en" you get different (wrong) stemming, but only for the lowercase version. You can verify this with tracelevel (tracelevel=1 is sufficient for that).

In general, if you have a single language, it's best to always just set locale to that explicitly (by default, locale is guessed, but this unreliable for very short texts such as many queries). If you're dealing with multiple languages things get a bit more complicated.

Related