boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
9.03k stars 1.87k forks source link

Hi, I am facing a issue using 'SpellCorrectionConfiguration' in Kendra Client query with boto3. I am not seeing a complete response, 'SpellCorrectedQueries' is not available in response even after setting SpellCorrectionConfiguration parameter. #3196

Closed SandeepPasula898 closed 2 years ago

SandeepPasula898 commented 2 years ago

My source code to call Kendra query : import boto3 import botocore

kendra = boto3.client( 'kendra', aws_access_key_id = ACCESS_KEY, aws_secret_access_key = SECRET_KEY, region_name = AWS_REGION)

KENDRA_INDEX = INDEX_ID response = kendra.query(IndexId=KENDRA_INDEX, QueryText='calendar', SpellCorrectionConfiguration= {'IncludeQuerySpellCheckSuggestions': True}) print(response)

Response

Kendra_respose_format

i

Versions boto3 - 1.21.22 botocore - 1.24.22 python - 3.8 `` Reference used - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/kendra.html#kendra.Client.query

tim-finnigan commented 2 years ago

Hi @SandeepPasula898 thanks for reaching out. I could reproduce the behavior you described. But I think that result is expected. If I spell a word incorrectly, for example “calendare”, then SpellCorrectedQueries is returned in the output:

   "SpellCorrectedQueries": [
        {
            "SuggestedQueryText": "calendar",
            "Corrections": [
                {
                    "BeginOffset": 0,
                    "EndOffset": 8,
                    "Term": "calendare",
                    "CorrectedTerm": "calendar"
                }
            ]
        }
    ],
github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

SandeepPasula898 commented 2 years ago

Hi @tim-finnigan thanks for the response. I have tested this again, and not able to get "SpellCorrectedQueries" key in response. May I know, what could be the issue. Please, let me know the specific versions of boto3, botocore and python you have used reproducing the above behaviour. All I get from the response are "QueryID", "ResultItems", "FacetResults", "TotalNoOfResults" and "ResponseMetadata" keys.

tim-finnigan commented 2 years ago

Hi @SandeepPasula898, I am using boto3 v1.21.20, botocore v1.24.20, and Python v3.9.6. Did you try adding a typo to your QueryText? For example QueryText='calendare'. Only by doing that was I able to get SpellCorrectedQueries returned.

SandeepPasula898 commented 2 years ago

Hi @tim-finnigan, Yes I have added typo QueryText='calendare'. Please check the response I am getting from below image and help me with this.

kendra_spell_correction

.

tim-finnigan commented 2 years ago

Hi @SandeepPasula898 which region are you using? I'm not sure if that is a factor but I'm using us-west-2 and can try to reproduce in your region.

SandeepPasula898 commented 2 years ago

Hi @tim-finnigan I am using 'us-east-1' region

tim-finnigan commented 2 years ago

Hi @SandeepPasula898 I think I found the issue after trying to reproduce this again. The term you are searching for needs to exist in the data source connected to your index. Or in the case of making a typo, you need the word to closely resemble a word that exists in your data source. Also you should sync your data to make sure that it is connected. I had to click the "Sync now" button in the console:

image

The spell checker query was just announced recently so I’m sure the Kendra team is still improving the documentation around this. In the meantime you could also try asking general Kendra questions at https://repost.aws/.



SandeepPasula898 commented 2 years ago

Hi @tim-finnigan , Yes I have that 'calendar' word in kendra indexed data. I am getting expected results when my QueryText='calendar' but not with QueryText='calendare'. Currently I am working on FAQ content in Kendra, FAQs are stored in S3. Will this feature works with only datasources, not FAQs? Below image shows that calendar word is available in Kendra FAQ.

kendra_search
tim-finnigan commented 2 years ago

Hi @SandeepPasula898 thanks for following up. Could you provide a sample FAQ file that I could use to try and reproduce?

Also I found this documentation that notes the limitations with Kendra's query Spell Checker: https://docs.aws.amazon.com/kendra/latest/dg/query-spell-check.html

Can you confirm that your query meets the criteria listed there?

SandeepPasula898 commented 2 years ago

Hi @tim-finnigan, Yes I have gone through limitations in documentation, my query meets the criteria. I am providing sample FAQ file which contains questions related to calendar. You can reproduce with same 'calendar' word sample.csv The steps I followed:

  1. Stored the FAQ file in S3 bucket
  2. Created a FAQ in Kendra index with this FAQ CSV as shown below. Kendra-FAQs
tim-finnigan commented 2 years ago

Hi @SandeepPasula898 thanks for providing that file. I also did not receive SpellCorrectedQueries when testing that file with FAQs.

I’m going to reach out to the Kendra team for guidance on this. I created a new issue for this here in our shared SDK repository since this applies to the underlying API used across SDKs: https://github.com/aws/aws-sdk/issues/214

I’m closing this issue but please refer to that one for updates.

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

SandeepPasula898 commented 2 years ago

Hi @tim-finnigan, Thanks I will refer to that new request.