#community-help

Understanding Search Parameters and Functions in a Database

TLDR Mubashirullah needed help with formulating search queries. Kishore Nallan explained how to use filter_by, query_by, and facet_query. The thread ended with corrections to a search syntax error.

Powered by Struct AI

2

1

1

1

Dec 21, 2021 (25 months ago)
Mubashirullah
Photo of md5-cea7a558edb0c66a1c07dfdcf00bc141
Mubashirullah
10:11 AM
I need help with understanding search.
I'm confused as to why I can't enter numbers in the query_by search parameter. If I want all results between 2 dates, am I suppose to add * in the q and all string fields in the query_by. In filter_by I include a range category :[timestamp_checkin timestamp_checkout]
I have checkIn and checkOut as separate fields. How do I formulate my search query? Thanks
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:17 AM
filter_by=checkIn:>8283838 && checkout:<747473

1

1

Mubashirullah
Photo of md5-cea7a558edb0c66a1c07dfdcf00bc141
Mubashirullah
10:25 AM
fantastic. And I could do something similar to nights stayed which is also a number. I'll have a * in q, query_by will be one field (does it even matter what query_by is) and then filter_by=nights:1
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:25 AM
For q=* query_by does not matter.
10:26
Kishore Nallan
10:26 AM
You can add as many && conditions as you want to the filter clause. However we don't support cross-field ORs yet.
Mubashirullah
Photo of md5-cea7a558edb0c66a1c07dfdcf00bc141
Mubashirullah
10:30 AM
Got it.
I'm a bit lost as to why facet_query exits. I have a field that filtery_by can filter for me.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:31 AM
Facet query can be used to allow users to search into a field values, like the "search within brands" feature on the left sidebar: https://ecommerce-store.typesense.org/
10:33
Kishore Nallan
10:33 AM
This part.

1

Mubashirullah
Photo of md5-cea7a558edb0c66a1c07dfdcf00bc141
Mubashirullah
11:27 AM
I was hoping facet_query would filter the results but it didn't
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:28 AM
What problem are you facing that you want to use facet query for?
Mubashirullah
Photo of md5-cea7a558edb0c66a1c07dfdcf00bc141
Mubashirullah
11:44 AM
On the current interface, if the user clicked on one of these values, I wanted the results to filter itself. I think filter_by is what I need.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:45 AM
Yes you need filter by

1

Dec 22, 2021 (25 months ago)
Mubashirullah
Photo of md5-cea7a558edb0c66a1c07dfdcf00bc141
Mubashirullah
08:02 AM
When I do
...checkIn:>={} && checkOut:=<{}'.format(_dateConvertion('2021-12-19'), _dateConvertion('2021-12-20'))

I don't get anyresults. When I change the checkout date to 2021-12-21 then I see the results with checkout date 2021-12-20.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:02 AM
What does _dateConvertion do?
Mubashirullah
Photo of md5-cea7a558edb0c66a1c07dfdcf00bc141
Mubashirullah
08:05 AM
08:05
Mubashirullah
08:05 AM
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:06 AM
Btw, it must be checkout: &lt;= {}
08:06
Kishore Nallan
08:06 AM
Not =&lt;
Mubashirullah
Photo of md5-cea7a558edb0c66a1c07dfdcf00bc141
Mubashirullah
08:07 AM
Yup, that was it. Silly me. Sorry to bother. Thank you

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads

Fixing Multiple Document Retrieval in Typesense

Phil needed an efficient way to retrieve multiple documents by id. Kishore Nallan proposed a solution available in a pre-release build. After some bug fixing regarding id matching by Jason and Kishore Nallan, Phil successfully tested the solution.

4

26
26mo

Issue with Numerical Faceting in Combination with Group_by

Vamshi encounters issues with numerical faceting when used in conjunction with group_by in Typesense. After a detailed query script, Kishore Nallan identifies this as a bug, encouraging the user to raise a Github issue.

7
3mo

Understanding Facet Query and Filter By on Typesense

Ricardo needed clarification on using facet_query. Kishore Nallan explained its use alongside `filter_by`, helping Ricardo understand the concepts. The discussion also touched upon how facet_query works with sets of fields and the difference between facet_query and filter_by.

22
33mo

Moving from Algolia to Typesense: Questions and Answers

Juan sought advice from Kishore Nallan about moving from Algolia to Typesense, handling MultiSearch, setting parameters, checking imported documents, and a specific syntax query.

1

22
22mo

Fuzzy Search Restrictions and num_typos Extension Request

Ashwin seeks to limit the fields covered by fuzzy search and wants specification of typo tolerance per field. Kishore Nallan suggests num_typos syntax to control the behavior, with Ashwin agreeing and planning to raise a related issue on Github. Jason advises on comparing integer time stamps for InstantSearch usage.

2

30
34mo