Cannot explain knn search results in Opensearch

any help would be appreciated with explaining search results with knn cosinesimil.

I am using AWS Opensearch Serverless and have created an index with several fields, of which one is a vector field. I first index my documents where the text body (2000-5000 characters) is converted to a vector with the universal-sentence-encoder model (multilingual-large). Before conversion there is some text pre-processing being done where stop words are removed from the text, punctuation marks, etc. The resulting vector has 512 dimensions and is part of my aoss index.

In the second phase i take some user input (20-800 characters) in the application and do the same text processing and vectorization which is done during indexing, and perform a search.
This is the query that i do to search for documents in aoss:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>GET _search
{
"size": 100,
"query": {
"bool": {
"must": [
{
"script_score": {
"query": {
"match_all": {}
},
"script": {
"source": "knn_score",
"lang": "knn",
"params": {
"field": "vector",
"query_value": [-0.030469229444861412,0.00919314380735159,.... <full vector ommitted for brevity>],
"space_type": "cosinesimil"
}
},
"min_score": 0.0,
"boost": 0.5
}
}
]
}
}
}
</code>
<code>GET _search { "size": 100, "query": { "bool": { "must": [ { "script_score": { "query": { "match_all": {} }, "script": { "source": "knn_score", "lang": "knn", "params": { "field": "vector", "query_value": [-0.030469229444861412,0.00919314380735159,.... <full vector ommitted for brevity>], "space_type": "cosinesimil" } }, "min_score": 0.0, "boost": 0.5 } } ] } } } </code>
GET _search
{
  "size": 100,
  "query": {
    "bool": {
      "must": [
        {
  "script_score": {
    "query": {
      "match_all": {}
    },
    "script": {
      "source": "knn_score",
      "lang": "knn",
      "params": {
        "field": "vector",
        "query_value": [-0.030469229444861412,0.00919314380735159,.... <full vector ommitted for brevity>],
        "space_type": "cosinesimil"
      }
    },
    "min_score": 0.0,
    "boost": 0.5
  }
}
      ]
    }
  }
}

I have been reading about the cosinesimil formula Exact k-NN with scoring script – OpenSearch Documentation and how it is used to score the results, so i get the boost and how the score is derived.

But, what is happening in my specific use case, is that the result documents found by Opensearch are too similar and do not appear to be that relevant for the data which is in the index. The scores are simply too close to each other, and some documents at the top of the results do not seem to be that relevant.
For example when i use a text snippet which is really relevant compared to indexed data, i get back “max_score”: 0.68753433 and the 100th result item score is 0.615429. Here my expectation is that i am close to 1 with this input.
On the other hand if i take some completely nonsense text which is syntactically and semantically correct but is totally irrelevant for the data in the index i get back “max_score”: 0.6175947, and the 100th result item score is 0.5619706. In this case my expectation is that the results are much closer to 0.

Does anyone have an idea what could be my issue and how to debug/test this problem? Is my search query syntax wrong in any way, or is it probably a problem with the vectorization of text? Any hints would be really appreciated, thanks!

New contributor

Hrvojeee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật