#community-help

Querying Multiple String Requirements on a Single Field

TLDR Todd had a query on string requirements on a single field using the 'q' parameter. Jason clarified and guided suggesting using filter_by=field:word1 for desired results.

Powered by Struct AI

2

1

1

1

10
17mo
Solved
Join the chat
Jun 10, 2022 (17 months ago)
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
09:03 PM
Hey all, just a small question. Anyone know if there is a way to query multiple required strings on a single field using the q parameter?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:04 PM
You want to set drop_tokens_threshold to 0 and/or surround the search terms with "quotes"
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
09:05 PM
Oh wow, that’s super straightforward. Thanks!

1

Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:05 PM
Btw, I assumed you're only setting a single field in query_by
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
09:05 PM
Ruh roh! I was going to use two. Does that break it?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:06 PM
If you have multiple fields in query_by, then the only other way to do what you want to do is to use filter_by=field:word1
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
09:06 PM
Hm. What happens if I have two fields? In this case, I’m okay with the matches being in either field/
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:07 PM

1

Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
09:07 PM
Sweet! We are good to roll then. Thank you again sir, nice piece of software!

1

1

09:13
Todd
09:13 PM
Hah, I was going to ask another question, but you actually answered it here already.

If I want to do a filter_by clause on a string, can I do an includes type of operation? The answer is yes, you do filter_by=field:word1

1