4

I am looking at Amazon CloudSearch, and am just concerned about having multiple values per column, and if it would be considered as an individual facet by the CloudSearch. What I mean is, if I have a book (1 row) and it has multiple authors, but only one author field, how can the faceted search return each individual author as a separate facet? It wouldn't be that practical to have to set-up a hard-coded set of author fields (ie.. author1,author2,author3) so I'm wondering if it's something built in?

I don't see it being supported, but then again I don't know everything. The way I see it it can accept a CSV value of some sort, or XML?

An example of what I mean is like if I had this data set stored on CloudSearch:

   title        |  author
   I am a book  |  Bob Jones, Mike Miller

But these would be the facets returned:

   author
     -Bob Jones
     -Mike Miller

Any way to achieve something like this?

Control Freak
  • 12,965
  • 30
  • 94
  • 145

1 Answers1

3

A facet does precisely what you ask, but you can't return a facet.

So if you created your author field as a facet and you searched title for "book" and returned the facet "author"

/search?q=book&facet=author

you would get back facet with: Bob Jones (1) and Mike Miller (1) with 1 hits. Indicating that there is one book for Bob and one for Mike (in your case the same book).

BUT what is missing is the "authors" field, your facet would in no way show that the both authors belong to the same book. Neither could you display the authors with the book, unless you add an extra field that list the authors in one string or author1 author2.

As for how to insert multiple values for one field, an array, I use the method of posting a json object to /documents/batch. The author field would simply have an array with one or more values (an empty array is not allowed, an empty string is, a book with no authors must be an empty string, not an empty array in your json object).

Didier
  • 136
  • 1
  • 1
  • 6
  • 2
    I was trying to do something similar, and CloudSearch can be set up to do what I think you want. The key is to set up your "author" field as a type literal-array, which then can be faceted (unlike type text-array). Then in your example, you would set the value to be the array ("Bob Jones", "Mike Miller") and when you did a search, you would get back the faceted results with the counts of all matches for each of the different authors. – Rolf Kaiser Jul 14 '15 at 16:01