#community-help

Filter Search Result Strategies

TLDR Sandip asked how to filter string search results. Kishore Nallan recommended using infix and prefix search, but mentioned exact matching as a limitation in filtering.

Powered by Struct AI
Aug 18, 2023 (1 month ago)
Sandip
Photo of md5-15d14f788c619474a46b8fb0c08210bb
Sandip
05:07 AM
Hi Kishore Nallan, Jason
Can I filter search result for string using following scenario:
1. Contains with ""
2. Start with ""
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
05:10 AM
For contains check on the infix query option. However you need to enable that index during collection creation and it can be quite performance intensive.

Starts with is supported by prefix search which is enabled by default.
Sandip
Photo of md5-15d14f788c619474a46b8fb0c08210bb
Sandip
05:20 AM
{
                    "accessible_to_user_ids": [
                        "923e691f-0eb3-412c-b46c-3926dd33a29c",
                        "b54fef2d-27a4-4926-a3fa-64aba5c4f89b"
                    ],
                    "ca": "2023-04-19T09:05:18.133336Z",
                    "comments": [],
                    "created_at": 0,
                    "description": "",
                    "id": "c25c3a95-f126-4bb3-b7a4-17a9e41d9fd8",
                    "labels": [
                        "Donna"
                    ],
                    "labels_id": [
                        "207ea014-b787-417e-aa15-5cc9a306a79c"
                    ],
                    "name": "Susan White",
                    "opening_id": "4ecf3c24-560b-4821-a427-e2df399f3d0b",
                    "opening_name": "Test data",
                    "sys_org_id": "0db9d32b-e9b9-4578-9c5c-5fc4260f1fd2",
                    "ua": "2023-04-19T09:05:18.133336Z",
                    "updated_at": 0
                }

This is my document and below is search query:

{
    "q": "su",
    "query_by": "name",
    "filter_by":"opening_name:ta"
}
05:21
Sandip
05:21 AM
I want to search result that name start with "su" and filter_by with opening_name that contains "ta". but it gets empty result.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:44 AM
You can only do exact searching on filters