Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full-text search #352

Closed
joshvillbrandt opened this issue Jun 1, 2014 · 2 comments
Closed

Full-text search #352

joshvillbrandt opened this issue Jun 1, 2014 · 2 comments

Comments

@joshvillbrandt
Copy link
Contributor

Does the existing filtering infrastructure support full-text searches? I'd be pretty surprised if Eve doesn't already support searching for partial text within a field or within multiple fields. Can somebody help me out?

@joshvillbrandt
Copy link
Contributor Author

I was getting OperationFailure: database error: invalid operator: $search errors when trying to use the $text query operator. Looks like I needed MongoDB >= 2.4. (My development server automatically had 2.6, so I thought my production server would too.) Anyway, this will hopefully fix it. I'll report back soon!

Assuming this works, we should add some helpful text in the Eve docs.

@joshvillbrandt
Copy link
Contributor Author

Alright, I've finally put the pieces together!

So first off, I needed to remove '$regex' from MONGO_DBNAME_BLACKLIST setting. The where parameter of my http query ended up looking like this:

{'name': {
    '$regex': search,
    '$options': 'i'
}}

For what it is worth, I was using AngularJS to make the http query. Since Angular strips attributes that starts with $, I also had to pre-stringify the that object using JSON.stringify() befor handing it to Angular. (The Angular team is planning a fix for this in 1.3. See Angular issue #1463.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant