groonga / gcs

Groonga CloudSearch is an open source implementation of Amazon CloudSearch.
http://gcs.groonga.org/
MIT License
25 stars 1 forks source link

Match behaviour of "return-fields" parameter with missing/noresult field to the one of Amazon CloudSearch #94

Closed piroor closed 12 years ago

piroor commented 12 years ago

There is no document about such cases.

For missing fields, should we return error responses? Or, simply ignore them? For "noresult" fields, how should we treat them?

darashi commented 12 years ago

All cases returned 200 OK but the behaviors are slightly different in details.

1) If we do not have return-field specified, the data key in hit array is not appeared:

{"rank":"-text_relevance","match-expr":"(label title:'movie')","hits":{"found":31,"start":0,"hit":[{"id":"tt0795461"},{"id":"tt0823188"},{"id":"tt0092106"},{"id":"tt0462538"},{"id":"tt0306047"},{"id":"tt1679332"},{"id":"tt0120389"},{"id":"tt0345950"},{"id":"tt0389790"},{"id":"tt1571739"}]},"info":{"rid":"8b46e820abdf9c2b6422cf05f897b7f6618a83ca20c7e5ca20ada6f5d352a8dafa433e0a5566b9cc","time-ms":3,"cpu-time-ms":4}}

2) If we specified the non-exist field only, for return-fields, empty "data": {} is included in the elements of the hit array:

earch.amazonaws.com/2011-02-01/search?bq=title:'movie'&return-fields=not-exist"
{"rank":"-text_relevance","match-expr":"(label title:'movie')","hits":{"found":31,"start":0,"hit":[{"id":"tt0795461","data":{}},{"id":"tt0823188","data":{}},{"id":"tt0092106","data":{}},{"id":"tt0462538","data":{}},{"id":"tt0306047","data":{}},{"id":"tt1679332","data":{}},{"id":"tt0120389","data":{}},{"id":"tt0345950","data":{}},{"id":"tt0389790","data":{}},{"id":"tt1571739","data":{}}]},"info":{"rid":"8b46e820abdf9c2b6422cf05f897b7f64782dd96071f4452e88d463e57c3d7082d3c52ec7337b978","time-ms":3,"cpu-time-ms":4}}

3) If we specified both non-existent fields and existent fields, non-existent fields are simply ignored:

{"rank":"-text_relevance","match-expr":"(label title:'movie')","hits":{"found":31,"start":0,"hit":[{"id":"tt0795461","data":{"title":["Scary Movie 5"]}},{"id":"tt0823188","data":{"title":["The Sex Movie"]}},{"id":"tt0092106","data":{"title":["The Transformers: The Movie"]}},{"id":"tt0462538","data":{"title":["The Simpsons Movie"]}},{"id":"tt0306047","data":{"title":["Scary Movie 3"]}},{"id":"tt1679332","data":{"title":["Ultramarines: A Warhammer 40,000 Movie"]}},{"id":"tt0120389","data":{"title":["Turbo: A Power Rangers Movie"]}},{"id":"tt0345950","data":{"title":["The SpongeBob SquarePants Movie"]}},{"id":"tt0389790","data":{"title":["Bee Movie"]}},{"id":"tt1571739","data":{"title":["This Movie Is Broken"]}}]},"info":{"rid":"8b46e820abdf9c2b6422cf05f897b7f602f78cc3d6ac673dff0003d47d50f29e948b31dcf5544547","time-ms":3,"cpu-time-ms":0}}

4) If the field does exist and is noresult (in this example genre faceted field is used), the empty value for the field is returned:

{"rank":"-text_relevance","match-expr":"(label title:'movie')","hits":{"found":31,"start":0,"hit":[{"id":"tt0795461","data":{"genre":[]}},{"id":"tt0823188","data":{"genre":[]}},{"id":"tt0092106","data":{"genre":[]}},{"id":"tt0462538","data":{"genre":[]}},{"id":"tt0306047","data":{"genre":[]}},{"id":"tt1679332","data":{"genre":[]}},{"id":"tt0120389","data":{"genre":[]}},{"id":"tt0345950","data":{"genre":[]}},{"id":"tt0389790","data":{"genre":[]}},{"id":"tt1571739","data":{"genre":[]}}]},"info":{"rid":"8b46e820abdf9c2b6422cf05f897b7f66bc1f9dad73bf90112ef64431e6e48dfbf6f08324e920be5","time-ms":3,"cpu-time-ms":0}}
piroor commented 12 years ago

Done. Thanks!