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

IndexError: list index out of range #7

Open
bakhtiarkamal opened this issue Sep 28, 2023 · 4 comments
Open

IndexError: list index out of range #7

bakhtiarkamal opened this issue Sep 28, 2023 · 4 comments

Comments

@bakhtiarkamal
Copy link

Getting a list index out of range error, as below:

File "C:\PyProjects\elastic-ChatGPT\rsllc-elastic-env\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 541, in _run_script exec(code, module.__dict__) File "C:\PyProjects\elastic-ChatGPT\elastic-gpt.py", line 116, in <module> resp, url = search(query) File "C:\PyProjects\elastic-ChatGPT\elastic-gpt.py", line 83, in search body = resp['hits']['hits'][0]['fields']['body_content'][0]

The error is happening in the streamlit script for the line
body = resp['hits']['hits'][0]['fields']['body_content'][0]

The output of
resp = es.search(index=index, query=query, knn=knn, fields=fields, size=1, source=False)
is
{'took': 44, 'timed_out': False, '_shards': {'total': 2, 'successful': 2, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 0, 'relation': 'eq'}, 'max_score': None, 'hits': []}}

I've followed the instructions in the blog but unsure why getting a list index out of range

@noumanaziz7241
Copy link

noumanaziz7241 commented Oct 11, 2023

I am Encountering same error on Ubuntu. I followed each and every step described in the blog but got the error.
my error is also in same line i.e.

resp = es.search(index=index, query=query, knn=knn, fields=fields, size=1, source=False)

while my output for this is

{'took': 11, 'timed_out': False, '_shards': {'total': 2, 'successful': 2, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 0, 'relation': 'eq'}, 'max_score': None, 'hits': []}}

Please provide any solution for this

@AlexandrKostrov
Copy link

AlexandrKostrov commented Oct 18, 2023

The same error. Elastic returns no hits on every question about elastic docs

@AlexandrKostrov
Copy link

The same error. Elastic returns no hits on every question about elastic docs

It's not working for me on 8.10.3 deployment version but works fine on 8.9 with fix from this closed issue - #4.
@jeffvestal can you check please, what is a problem with running this on 8.10.3?

Thanks

@dynamite-bud
Copy link

Hey, I found the issue.
The problem is it's trying to query on the field of title-vector. But as they updated the inferences to be stored in ml.inference.title.predicted_value update that in your queries:

    query = {
        "bool": {
            "must": [{
                "match": {
                    "title": {
                        "query": query_text,
                        "boost": 1
                    }
                }
            }],
            "filter": [{
                "exists": {
                    "field": "ml.inference.title.predicted_value"
                }
            }]
        }
    }

The above solved it for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants