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

Fix NullPointerException when doing knn search on empty index without dims #111756

Merged
merged 4 commits into from
Aug 9, 2024

Conversation

kderusso
Copy link
Member

@kderusso kderusso commented Aug 9, 2024

Resolves #111733

Script to reproduce (slightly expanded from bug report issue):

DELETE esre-team-test-chunks

PUT esre-team-test-chunks
{
  "mappings": {
    "dynamic_templates": [],
    "properties": {
      "metadata": {
        "properties": {
          "esre": {
            "properties": {
              "created_at": {
                "type": "date"
              },
              "embedding_model": {
                "type": "text"
              },
              "file_id": {
                "type": "text"
              },
              "team_id": {
                "type": "text"
              },
              "updated_at": {
                "type": "date"
              }
            }
          },
          "source": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      },
      "text": {
        "type": "text",
        "fields": {
          "ngram": {
            "type": "text"
          }
        }
      },
      "text_embedding": {
        "type": "dense_vector",
        "index": true,
        "similarity": "cosine"
      }
    }
  }
}


PUT _inference/text_embedding/my-e5-model
{
  "service": "elasticsearch",
  "service_settings": {
    "num_allocations": 1,
    "num_threads": 1,
    "model_id": ".multilingual-e5-small"
  }
}

GET /esre-team-test-chunks/_search
{
  "fields": [
    "text"
  ],
  "knn": {
    "field": "text_embedding",
    "k": 10,
    "num_candidates": 100,
    "query_vector_builder": {
      "text_embedding": {
        "model_id": ".multilingual-e5-small",
        "model_text": "test"
      }
    }
  }
}

GET /esre-team-test-chunks/_search
{
  "fields": [
    "text"
  ],
  "knn": {
    "field": "text_embedding",
    "k": 10,
    "num_candidates": 100,
    "query_vector": [ 1.0, 2.0, 3.0 ]
  }
}

@elasticsearchmachine
Copy link
Collaborator

Hi @kderusso, I've created a changelog YAML for you.

@kderusso kderusso added the :SearchOrg/Relevance Label for the Search (solution/org) Relevance team label Aug 9, 2024
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some whitespace changes auto-generated by IDE - "Hide whitespace" to make this more readable.

@kderusso kderusso marked this pull request as ready for review August 9, 2024 15:44
@kderusso kderusso requested a review from a team August 9, 2024 15:44
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/search-relevance (Team:Search - Relevance)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ent-search-eng (Team:SearchOrg)

Copy link
Contributor

@Samiul-TheSoccerFan Samiul-TheSoccerFan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kderusso
Copy link
Member Author

kderusso commented Aug 9, 2024

@elasticmachine update branch

@kderusso kderusso merged commit 4e26114 into elastic:main Aug 9, 2024
15 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.15 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 111756

@kderusso
Copy link
Member Author

kderusso commented Aug 9, 2024

💚 All backports created successfully

Status Branch Result
8.15

Questions ?

Please refer to the Backport tool documentation

kderusso added a commit to kderusso/elasticsearch that referenced this pull request Aug 9, 2024
… dims (elastic#111756)

* Fix NullPointerException when doing knn search on empty index without dims

* Update docs/changelog/111756.yaml

* Fix typo in yaml test

---------

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit 4e26114)

# Conflicts:
#	rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.vectors/40_knn_search.yml
kderusso added a commit that referenced this pull request Aug 9, 2024
…without dims (#111756) (#111763)

* Fix NullPointerException when doing knn search on empty index without dims (#111756)

* Fix NullPointerException when doing knn search on empty index without dims

* Update docs/changelog/111756.yaml

* Fix typo in yaml test

---------

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit 4e26114)

# Conflicts:
#	rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.vectors/40_knn_search.yml

* Update 40_knn_search.yml

* Yaml
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Sep 4, 2024
… dims (elastic#111756)

* Fix NullPointerException when doing knn search on empty index without dims

* Update docs/changelog/111756.yaml

* Fix typo in yaml test

---------

Co-authored-by: Elastic Machine <[email protected]>
davidkyle pushed a commit to davidkyle/elasticsearch that referenced this pull request Sep 5, 2024
… dims (elastic#111756)

* Fix NullPointerException when doing knn search on empty index without dims

* Update docs/changelog/111756.yaml

* Fix typo in yaml test

---------

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vector search error when the target index is empty
5 participants