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

Specifying multiple returnFields values #450

Closed
blowmage opened this issue Dec 2, 2015 · 8 comments
Closed

Specifying multiple returnFields values #450

blowmage opened this issue Dec 2, 2015 · 8 comments
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@blowmage
Copy link
Contributor

blowmage commented Dec 2, 2015

In #442 @yyr2015 wrote:

Setting "returnFields=*" returns all fields in each document. Setting "returnFields=field1" returns only field1 in each document, and setting "returnFields=field1&returnFields=field2" returns field1 and field2 in each document.

We can not specify returnFields, and set returnFields to a single value, but cannot set returnFields to multiple values. Only the last value is returned. The following are the requests made to the Search API and their responses. The requests are all authenticated with signet.

No fields specified and no fields returned

https://cloudsearch.googleapis.com/v1/projects/nodal-almanac-725/indexes/test/search?query=ruby

{
  "results": [
    {
      "docId": "gcloud-ruby",
      "nextPageToken": "..."
    }
  ],
  "matchedCount": "1"
}

All fields specified (using "*") and all fields returned

https://cloudsearch.googleapis.com/v1/projects/nodal-almanac-725/indexes/test/search?query=ruby&returnFields=%2A

{
  "results": [
    {
      "docId": "gcloud-ruby",
      "fields": {
        "summary": {
          "values": [
            {
              "stringValue": "Idiomatic Ruby client for Google Cloud Platform services.",
              "stringFormat": "TEXT"
            }
          ]
        },
        "title": {
          "values": [
            {
              "stringValue": "gcloud-ruby",
              "stringFormat": "TEXT"
            }
          ]
        },
        "description": {
          "values": [
            {
              "stringValue": "Gcloud is the official library for interacting with Google Cloud.",
              "stringFormat": "TEXT"
            }
          ]
        }
      },
      "nextPageToken": "..."
    }
  ],
  "matchedCount": "1"
}

One field specified ("title") and one field returned

https://cloudsearch.googleapis.com/v1/projects/nodal-almanac-725/indexes/test/search?query=ruby&returnFields=title

{
  "results": [
    {
      "docId": "gcloud-ruby",
      "fields": {
        "title": {
          "values": [
            {
              "stringValue": "gcloud-ruby",
              "stringFormat": "TEXT"
            }
          ]
        }
      },
      "nextPageToken": "..."
    }
  ],
  "matchedCount": "1"
}

Two fields specified ("title" and "description") but only one field ("description") returned

https://cloudsearch.googleapis.com/v1/projects/nodal-almanac-725/indexes/test/search?query=ruby&returnFields=title&returnFields=description

{
  "results": [
    {
      "docId": "gcloud-ruby",
      "fields": {
        "description": {
          "values": [
            {
              "stringValue": "Gcloud is the official library for interacting with Google Cloud.",
              "stringFormat": "TEXT"
            }
          ]
        }
      },
      "nextPageToken": "..."
    }
  ],
  "matchedCount": "1"
}

Three fields specified ("title", "description", "summary") but only one field ("summary") returned

https://cloudsearch.googleapis.com/v1/projects/nodal-almanac-725/indexes/test/search?query=ruby&returnFields=title&returnFields=description&returnFields=summary

{
  "results": [
    {
      "docId": "gcloud-ruby",
      "fields": {
        "summary": {
          "values": [
            {
              "stringValue": "Idiomatic Ruby client for Google Cloud Platform services.",
              "stringFormat": "TEXT"
            }
          ]
        }
      },
      "nextPageToken": "..."
    }
  ],
  "matchedCount": "1"
}

(The nextPageToken values have been truncated.)

/cc @chrisnb and @yyr2015

@blowmage
Copy link
Contributor Author

blowmage commented Dec 7, 2015

@yyr2015 @chrisnb Ping? Any update on this?

@yyr2015
Copy link

yyr2015 commented Dec 8, 2015

I am not able to reproduce the problem. Can you please help try the following:

In a new index, add a simple document with 2 or 3 fields, like the example in our document:

{
    "docId": "doc1",
    "fields": {
        "field2": {
            "values": [{
                "stringValue": "\u003chtml\u003ehelloworld\u003c/html\u003e",
                "stringFormat": "HTML"
            }]
        },
        "field1": {
            "values": [{
                "stringValue": "helloworld",
                "stringFormat": "TEXT"
            }, {
                "timestampValue": "2014-08-18T21:19:55.000Z"
            }, {
                "numberValue": 10
            }, {
                "geoValue": "+40.6894,-074.0447"
            }]
        }
    }
}

Then try the search query to return all fields, 1 field or multiple fields.

@blowmage
Copy link
Contributor Author

blowmage commented Dec 8, 2015

Hi Yirong.

Then try the search query to return all fields, 1 field or multiple fields.

That's what the URLs and responses are in the description of this issue. We have no fields specified and returned, "*" specified and all fields returned, and then one, two, and three fields specified but only one field returned. I just tried this again and I get the same behavior.

Can you post the URL you are hitting, including the querystring, when specifying and returning multiple fields? We were told we need to use flat params, but perhaps we need to format the input differently? Only the last "returnFields" specified in the querystring is being returned from the search API. I would really like to see how you are specifying multiple "returnFields" values.

@yyr2015
Copy link

yyr2015 commented Dec 8, 2015

Here is what I tried:

  1. index the document:

https://cloudsearch.googleapis.com/v1/projects/yyr-testapp/indexes/test2/documents -d '{"docId": "gcloud-ruby", "fields": {"summary": {"values": [{"stringValue": "Idiomatic Ruby client for Google Cloud Platform services.", "stringFormat": "TEXT"}]}, "title": {"values": [{"stringValue": "gcloud-ruby", "stringFormat": "TEXT"}]}, "description": {"values": [{"stringValue": "Gcloud is the official library for interacting with Google Cloud.", "stringFormat": "TEXT"}]}}}'

{
"docId": "gcloud-ruby"
}

  1. search without returning any field:

https://cloudsearch.googleapis.com/v1/projects/yyr-testapp/indexes/test2/search?query=ruby

{
"results": [
{
"docId": "gcloud-ruby",
"nextPageToken": "......"
}
],
"matchedCount": "1"
}

  1. search with all fields returned:

https://cloudsearch.googleapis.com/v1/projects/yyr-testapp/indexes/test2/search?query=ruby&returnFields=%2A

{
"results": [
{
"docId": "gcloud-ruby",
"fields": {
"summary": {
"values": [
{
"stringValue": "Idiomatic Ruby client for Google Cloud Platform services.",
"stringFormat": "TEXT"
}
]
},
"title": {
"values": [
{
"stringValue": "gcloud-ruby",
"stringFormat": "TEXT"
}
]
},
"description": {
"values": [
{
"stringValue": "Gcloud is the official library for interacting with Google Cloud.",
"stringFormat": "TEXT"
}
]
}
},
"nextPageToken": "......"
}
],
"matchedCount": "1"
}

  1. search with only 1 field returned:

https://cloudsearch.googleapis.com/v1/projects/yyr-testapp/indexes/test2/search?query=ruby&returnFields=title

{
"results": [
{
"docId": "gcloud-ruby",
"fields": {
"title": {
"values": [
{
"stringValue": "gcloud-ruby",
"stringFormat": "TEXT"
}
]
}
},
"nextPageToken": "......"
}
],
"matchedCount": "1"
}

  1. search with 2 fields returned:

https://cloudsearch.googleapis.com/v1/projects/yyr-testapp/indexes/test2/search?query=ruby&returnFields=title&returnFields=description

{
"results": [
{
"docId": "gcloud-ruby",
"fields": {
"title": {
"values": [
{
"stringValue": "gcloud-ruby",
"stringFormat": "TEXT"
}
]
},
"description": {
"values": [
{
"stringValue": "Gcloud is the official library for interacting with Google Cloud.",
"stringFormat": "TEXT"
}
]
}
},
"nextPageToken": "......"
}
],
"matchedCount": "1"
}

  1. search with 3 fields returned:

https://cloudsearch.googleapis.com/v1/projects/yyr-testapp/indexes/test2/search?query=ruby&returnFields=title&returnFields=description&returnFields=summary

{
"results": [
{
"docId": "gcloud-ruby",
"fields": {
"summary": {
"values": [
{
"stringValue": "Idiomatic Ruby client for Google Cloud Platform services.",
"stringFormat": "TEXT"
}
]
},
"title": {
"values": [
{
"stringValue": "gcloud-ruby",
"stringFormat": "TEXT"
}
]
},
"description": {
"values": [
{
"stringValue": "Gcloud is the official library for interacting with Google Cloud.",
"stringFormat": "TEXT"
}
]
}
},
"nextPageToken": "......"
}
],
"matchedCount": "1"
}

@stephenplusplus
Copy link

Confirmed this works (when applied to this test case: googleapis/google-cloud-node#1012)

@blowmage
Copy link
Contributor Author

blowmage commented Dec 9, 2015

Oh man, the following comment was supposed to be posted yesterday:

Thank you very much! This is super helpful. Your querystrings match ours, so we must have something else going on in the request. We've tried the node and python libraries but they have other issues calling this as well.

I have identified the cause for this in the gcloud-ruby code and will post a fix later today. Thank you very much for your help!

@blowmage blowmage added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed status: blocked Resolving the issue is dependent on other work. labels Dec 9, 2015
@stephenplusplus
Copy link

To add more thanks in the mix, thank you @blowmage for catching this in the first place, since Node also had problems making a proper request. 👊

@blowmage
Copy link
Contributor Author

blowmage commented Dec 9, 2015

@stephenplusplus I should have some updated acceptance tests that will use returnFields and fieldExpressions either later today or early tomorrow. Keep an eye on #448.

blowmage added a commit to blowmage/google-cloud-ruby that referenced this issue Dec 9, 2015
Faraday re-parses the URI provided to it, so make sure it is using the
flat parameters setting.

[fixes googleapis#450]
@blowmage blowmage closed this as completed Dec 9, 2015
blowmage added a commit that referenced this issue Dec 11, 2015
Faraday re-parses the URI provided to it, so make sure it is using the
flat parameters setting.

[fixes #450]
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants