watson-developer-cloud/assistant-with-discovery

Can someone kindly suggest a solution to Resolved issue #69?

619 opened this issue · 2 comments

619 commented

The author of the issue only mentioned the cause, and no solution. In addition, the code he mentioned at DiscoveryQuery.query(String userQuery) should be:

        sb.append("searchText:");
        sb.append(userQuery);
        sb.append(",");
        sb.append("enrichedText:");
        sb.append(userQuery);`

but is different...

Unless I am mistaken, this is what it looks like now:

public QueryResponse query(String userQuery) throws Exception {
    QueryRequest.Builder queryBuilder = new QueryRequest.Builder(environmentId, collectionId);
    
    StringBuilder sb = new StringBuilder();
    
    if(queryFields == null || queryFields.length() == 0 || queryFields.equalsIgnoreCase("none")) {
      sb.append(userQuery);
    } else {
      StringTokenizer st = new StringTokenizer(queryFields, ",");
      while (st.hasMoreTokens()) {
        sb.append(st.nextToken().trim());
        sb.append(":");
        sb.append(userQuery);
        if (st.hasMoreTokens()) {
          sb.append(",");
        }
      }
    }

    queryBuilder.query(sb.toString());
    QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute();

    return queryResponse;
  }

I'm still experiencing this issue, but when I enter "How do I check my tire pressure" my CEPayload looks like:

 "CEPayload": [
      {
        "body": "empty",
        "bodySnippet": "empty",
        "confidence": "0.0",
        "sourceUrl": "empty",
        "title": "No results found"
      }
    ] 

Instead of "CEPayload": []

Even though CEPayload should have returned 3 paragraphs like in the demo.
A solution would be much appreciated.

@stevenpkg I believe you put a fix in for this issue, where the Discovery service doesn't return a result?

Yes if no result is returned from conversation or discovery services, a message is displayed "Sorry I haven't learned answers to questions like this"