xivapi-py icon indicating copy to clipboard operation
xivapi-py copied to clipboard

XIVAPIClient.index_search() raises XIVAPIError with any wildcard query

Open Terlen opened this issue 4 years ago • 0 comments

Don't know if this repo is maintained anymore but thought I'd mention an error I ran into!

Passing any query to XIVAPIClient.index_search() with string_algo="wildcard" raises an XIVAPIError exception.

This occurs because the "wildcard" query type does not support the "query" parameter, as explained by the response.

{'Error': True, 
'Subject':` 'XIVAPI ERROR', 
'Note': 'Get on discord: https://discord.gg/MFFVHWC', 
'Message': 'Search Error: {
    "error":{
        "root_cause":[{
            "type":"parsing_exception",
            "reason":"[wildcard] query does not support [query]","line":1,"col":69
        }],
        "type":"parsing_exception",
        "reason":"[wildcard] query does not support [query]",
        "line":1,"col":69
    },
"status":400
}', 
'Hash': '61969353bd46e810ce74ee1177e0d79b0c1bf5f2', 
'Ex': 'App\\Common\\Exceptions\\SearchException', 
'ExCode': 500, 
'Url': '', 
'Debug': {
    'ID': 'Yn60aZfP21081602', 
    'File': '#55 xivapi.com/src/Controller/SearchController.php', 
    'Method': 'POST', 
    'Path': '/search', 
    'Action': 'App\\Controller\\SearchController::search', 
    'Code': 500, 
    'Date': '2021-08-16 14:10:10', 
    'Env': 'prod'
}
}`

This can be fixed by ensuring "wildcard" queries are constructed with the correct parameters like the following:

'wildcard': {
                NameCombined_en: {
                "value": name,
                "boost": 1.0,
                "rewrite": "constant_score"
                }
            }

Terlen avatar Aug 16 '21 14:08 Terlen