Skip to content

Using $and in query string #20

Closed
Closed
@Mattchewone

Description

@Mattchewone

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions