Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Creating a model from a non top level field causes a 'field does not exist' error #1293

Closed
karlney opened this issue Nov 3, 2023 · 1 comment · Fixed by #1318
Closed
Assignees
Labels
bug Something isn't working v2.12.0

Comments

@karlney
Copy link

karlney commented Nov 3, 2023

What is the bug?
It is not possible to train a model from a field that is not a top level field in the opensearch field mappings.

How can one reproduce the bug?
If I have a knn vector field located at the path vector.faiss.hnsw.inner_ef100_m16_flat that uses the following mappings

...
"mappings": {
     ...
    "properties": {
       ...
         "vector": {
          "dynamic": false,
          "properties": {
            "faiss": {
              "dynamic": false,
              "properties": {
                "hnsw": {
                  "dynamic": false,
                  "properties": {
                    "inner_ef100_m16_flat": {
                      "dimension": 768,
                      "method": {
                        "engine": "faiss",
                        "name": "hnsw",
                        "parameters": {
                          "ef_construction": 100,
                          "encoder": {
                            "name": "flat"
                          },
                          "m": 16
                        },
                        "space_type": "innerproduct"
                      },
                      "type": "knn_vector"
                    },
...

When I try to train a model from that field using the method described in https://opensearch.org/docs/latest/search-plugins/knn/api#usage-5

I get this error message

{"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: Field \"vector.faiss.hnsw.inner_ef100_m16_flat\" does not exist.;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: Field \"vector.faiss.hnsw.inner_ef100_m16_flat\" does not exist.;"},"status":400}

Even though I have confirmed that the field exists and that it has the correct data.

If I change the name of the field to top_vector and put it at the top of the mappings like this, and add the same data as before to the new field, THEN I can train a model.

...
"mappings": {
     ...
    "properties": {
       ...
         "top_vector": {
          "type": "knn_vector"
          ... all the same settings as above.. 
         }
...

I believe the error is in

Object fieldMapping = properties.get(field);
which makes the assumption that the field must be in the top of the properties hierarchy in the mappings, which is no documented in any documentation as far as I can tell, and even if it was, it seems like a weird limitation to not allow the vector field to be anywhere in the document.

@karlney karlney added bug Something isn't working untriaged labels Nov 3, 2023
@jmazanec15
Copy link
Member

I believe the error is in

Object fieldMapping = properties.get(field);

@karlney I think you are correct. Let me take a look at this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2.12.0
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants