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

Using $and in query string #20

Closed
Mattchewone opened this issue May 25, 2017 · 1 comment
Closed

Using $and in query string #20

Mattchewone opened this issue May 25, 2017 · 1 comment

Comments

@Mattchewone
Copy link
Contributor

Steps to reproduce

Maybe I am just being an idiot, but I cannot seem to get the $and to work in the query. I imagine this is less of a bug a more of I don't know the right syntax but I have tried a few.

Calling this endpoint: http://localhost:3030/search/tracks?tags.name.raw[$and]=rock
I've also tried: http://localhost:3030/search/tracks?$and[tags.name.raw]=rock But get an error about it not being an array.

Not sure what I am doing wrong but appreciate your help.

Expected behavior

This should be an anded filter term.

I am console.logging from the hooks, and the server service call gives me this in the hook under
hook.params.query: Hook query { '$and': { 'tags.name.raw': 'rock' } }
But the rest call is giving this:
Hook params { query: { 'tags.name.raw': { '$and': 'rock' } }

Actual behavior

It is not being run in the query at all. Added some debug and the $and filter in parseQuery is not being hit at all.

It does however work if I run it from the server as this:

service
	.find({
		query: {
			$and: [{
				'tags.name.raw': 'rock'
			}]
		}
	})
	.then(results => {
		console.log(JSON.stringify(results));
	});

System configuration

Latest version of feathers-elasticsearch.

@Mattchewone
Copy link
Contributor Author

Solved

It was the wrong syntax I was using, needs to be this:

http://localhost:3030/search/tracks?$and[][tags.name.raw]=rock

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