Multiple values in a single column for faceted search on Amazon CloudSearch supported?

2.1k Views Asked by At

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?

1

There are 1 best solutions below

1
On BEST ANSWER

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).