Repository navigation
Specifying multiple returnFields values #450
Description
Activity
- addedstatus: blockedResolving the issue is dependent on other work.Resolving the issue is dependent on other work.
on Dec 2, 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.
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.
Here is what I tried:
- 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"
}- 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"
}- search with all fields returned:
{
"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"
}- search with only 1 field returned:
{
"results": [
{
"docId": "gcloud-ruby",
"fields": {
"title": {
"values": [
{
"stringValue": "gcloud-ruby",
"stringFormat": "TEXT"
}
]
}
},
"nextPageToken": "......"
}
],
"matchedCount": "1"
}- search with 2 fields returned:
{
"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"
}- search with 3 fields returned:
{
"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"
}Confirmed this works (when applied to this test case: googleapis/google-cloud-node#1012)
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!
- addedtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.and removedstatus: blockedResolving the issue is dependent on other work.Resolving the issue is dependent on other work.
on Dec 9, 2015 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. 👊
@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.
- added a commit that references this issue
on Dec 9, 2015 - added a commit that references this issue
on Dec 11, 2015 - added🚨This issue needs some love.This issue needs some love.triage meI really want to be triaged.I really want to be triaged.
on Apr 6, 2020
In #442 @yyr2015 wrote:
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
All fields specified (using "*") and all fields returned
https://cloudsearch.googleapis.com/v1/projects/nodal-almanac-725/indexes/test/search?query=ruby&returnFields=%2A
One field specified ("title") and one field returned
https://cloudsearch.googleapis.com/v1/projects/nodal-almanac-725/indexes/test/search?query=ruby&returnFields=title
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
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
(The nextPageToken values have been truncated.)
/cc @chrisnb and @yyr2015