Gravatar for

Question by adharbert, Nov 10, 2014 3:50 PM

Does REST query allow for a contains condition

I am trying to query a field. I have a field name @fname60016, I would like to query it as a "Contains" instead of @fname60016=="xxxx". Is there a good way to do this? Again, this is with the JavaScript interface to call the REST api.

1 Reply
Gravatar for

Answer by Luc Bergeron, Nov 10, 2014 3:57 PM


I see two ways to do it. The first one is to use the "=" operator instead of "==". It will match the whole word using stemming like in a full text search.

Also, if your field is marked as facet, you could use the wildcard operator "*=". It can be handy if you are trying to match a specific part of a word. The query would look like this:

@fname60016 *= "*xxxx*"

Is it what you are looking for?

Gravatar for

Comment by adharbert, Nov 10, 2014 4:17 PM

Well, this query works @fname74285 == "product 28 350"

But this one does not work. @fname74285 *= "product"

Gravatar for

Comment by Luc Bergeron, Nov 10, 2014 4:20 PM

When using the wildcard operator, you should place the wildcard somewhere in your query. Otherwise it will behave as an exact match. I guess your query should look like this:

@fname74285 *= "product*"

Does it help?

Gravatar for

Comment by Martin Laporte, Nov 12, 2014 3:07 AM

Note: if you want to match a subset of the keywords of the field value vs a substring inside a keyword, I recommend you use the = operator instead as it's quite more efficient (it avoids a wildcard evaluation).

Gravatar for

Comment by adharbert, Nov 12, 2014 8:31 AM

My eyes are bad, I didn't the asterisk inside the quotes. Yes that worked!

Gravatar for

Comment by Simon, Nov 12, 2014 8:47 AM

Do not forget to accept the answer!

Ask a question