Searching for a regex in a list: #417
Replies: 2 comments 2 replies
-
Just to let you know I as able to do the search using a powerful but clunky
then:
And it worked as expected. Any less clunky and more direct ways? |
Beta Was this translation helpful? Give feedback.
-
Hey @igormorgado, the issue here is that by passing {'foo': [{'foo': 'One'}, {'foo': ' one'}]} But in your case you want to search for documents where any list entry matches your regex. Due to the way the query system is designed, it doesn't have great support for lists (it works best with lists of dicts). Given that, I think your solution is quite fine. If you want, you could express the same query a little more terse: def test_func(entries, search):
return any(search in entry.lower() for entry in entries) |
Beta Was this translation helpful? Give feedback.
-
I have the following documents in a database:
I would like to return all documents that field foo contains the word 'one', case insensitive.
I have tried:
But no luck.
Beta Was this translation helpful? Give feedback.
All reactions