Reputation: 13208
I'm testing Amazon Cloudsearch
for my web application and i'm running into some strange issues.
I have the following domain indexes: name
, email
, id
.
For example, I have data such as: John Doe, [email protected], 1
When I search for jo
I get nothing. If I search for joh
I still get nothing, But if I search for john
then I get the above document as a hit. Why is it not getting when I put partial strings? I even put suggestors on name
and email
with fuzzy matching enabled. Is there something else i'm missing? I read the below on this:
http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-text.html
http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching.html
http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-compound-queries.html
I'm doing the searches using boto as well as with the form on AWS page.
Upvotes: 5
Views: 6328
Reputation: 351
I think you must have your name
and email
fields set as the literal
type instead of the text
type, otherwise a simple text search of 'jo' or 'Joh' should've found the example document.
While using a prefix search may have solved your problem (and that makes sense if the fields are set as the literal
type), the accepted answer isn't really correct. The notion that it's "like a google search" isn't based on anything in the documentation. It actually contradicts the example they use, and in general muddies up what's possible with the service. From the docs:
When you search text and text-array fields for individual terms, Amazon CloudSearch finds all documents that contain the search terms anywhere within the specified field, in any order. For example, in the sample movie data, the title field is configured as a text field. If you search the title field for star, you will find all of the movies that contain star anywhere in the title field, such as star, star wars, and a star is born. This differs from searching literal fields, where the field value must be identical to the search string to be considered a match.
Upvotes: 0
Reputation: 51
Are your index field types "Text"? If they are just "Literals", they have to be an exact match.
Upvotes: 0
Reputation: 2681
What you're trying to do -- finding "john" by searching "jo" -- is a called a prefix search.
You can accomplish this either by searching
(prefix field=name 'jo')
or
q=jo*
Note that if you use the q=jo*
method of appending * to all your queries, you may want to do something like q=jo* |jo
because john*
will not match john
.
This can seem a little confusing but imagine if google gave back results for prefix matches: if you searched for tort and got back a mess of results about tortoises and torture instead of tort (a legal term), you would be very confused (and frustrated).
A suggester is also a viable approach but that's going to give you back suggestions (like john
, jordan
and jostle
rather than results) that you would then need to search for; it does not return matching documents to you.
See "Searching for Prefixes in Amazon CloudSearch" at http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-text.html
Upvotes: 14