Amazon Cloudsearch not searching with partial string
Asked Answered
T

3

5

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.

Tajo answered 28/4, 2015 at 16:37 Comment(0)
A
14

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

Ahead answered 29/4, 2015 at 2:8 Comment(2)
@Tajo @ALEXROUSSOS, how can i send query like q=jo* |jo or if i say multiple value query string with same q=jo*&q=|joDecomposer
@kvish : What if we needed to find John if user typed "oh" . How to go about that?Whim
H
0

Are your index field types "Text"? If they are just "Literals", they have to be an exact match.

Hecht answered 8/6, 2016 at 14:10 Comment(0)
G
0

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.

Gala answered 15/12, 2017 at 23:48 Comment(1)
defining name and email as Literal will make them case-sensitive too... and user never know s/he should type capital or lower letters to search...Decomposer

© 2022 - 2024 — McMap. All rights reserved.