aws / aws-sdk-js

AWS SDK for JavaScript in the browser and Node.js
https://aws.amazon.com/developer/language/javascript/
Apache License 2.0
7.6k stars 1.55k forks source link

cloudsearch SearchException #3940

Closed epsilonmb closed 1 year ago

epsilonmb commented 3 years ago

Describe the bug When searching for documents using CloudSearchDomain.search, if expression contains outcome of anther expression, SearchException is thrown.

Is the issue in the browser/Node.js? Node.js

If on Node.js, are you running this on AWS Lambda? No

Details of the browser/Node.js version Paste output of npx envinfo --browsers or node -v 12.20

SDK version number v2.1019.0

To Reproduce (observed behavior) 1) create cloudsearch domain with 2 fields

  1. country - type literal
  2. location - type latlon 2) run below query should throw error (doesn't require any data)

    const cloudSearchDomain = new AWS.CloudSearchDomain({
    endpoint:  xxx,
    apiVersion: "2013-01-01",  
    });
    const request: SearchRequest = {
    query: "country:'KR",
    expr: JSON.stringify({
      "distance": `haversin(37.548493,127.056094,location.latitude,location.longitude)`, 
      "myrank": "log10(distance)"
    }),
    queryParser: "structured",
    cursor: "initial",
    return: "distance"
    };  
    const searchResult = await cloudSearchDomain.search(request).promise();

    SearchException: undefined field: "distance"

Expected behavior No error should be thrown - Outcome of expression can be used as described in below link https://docs.aws.amazon.com/ko_kr/cloudsearch/latest/developerguide/searching-locations.html

Rest api works - myrank is calculated with distance https://xxx.ap-northeast-1.cloudsearch.amazonaws.com/2013-01-01/search?q.parser=structured&q=country:'KR'&expr.distance=haversin(38.958687,-77.343149,location.latitude,location.longitude)&expr.myrank=log10(distance)

Thanks in advance Scott

github-actions[bot] commented 1 year ago

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.