Please help were blocked from production because a...
# community-help
d
Please help were blocked from production because a value like 123456 won’t be hit if we query 0123456
j
By default, Typesense only returns matches where the search term occurs in the beginning of strings (this is called a prefix search) If you want to search in the middle of strings, it’s called an infix search and you can enable it by setting infix:true in the field definition in the collection schema, and then set infix=true as a search parameter
d
All infix can be prefix?
But prefix can’t be infix
Just making sure
Hmm it’s not working
Infix parameter for seaching is always or fallback I tried both and it doesn’t work. I have infix on my schema by patching via curl
Sorry if my question was vague but the bad query was the 0, when trying to match 123456
It matches for 012345670
But not for 01234567
It matches 0123456x Except when x= actual value
j
Just to make sure we’re on the same page, could you update this code snippet, with your schema settings, add a few sample docs and update the search query to replicate the issue? https://gist.github.com/jasonbosco/7c3432713216c378472f13e72246f46b
d
Ok I commented,
Are u able to reproduce ?
k
Hi Daren, we might not always be able to support typos at the start of the query because that tend to involve almost all the words in your dataset. Infix index won't help here if you are adding a letter at the start.
d
hmmm
Any workarounds? Or i have to switch to Algolia :/
k
I'll have to get back to you. Possible to give us a day or so?
d
Yeah
j
Copy-pasting the snippet from the GitHub comment here:
Copy code
export TYPESENSE_API_KEY=xyz

curl "<http://localhost:8108/debug>" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}"


curl "<http://localhost:8108/collections>" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
       -d '{
         "name": "numbers",
         "fields": [
           {"name": "handle", "type": "string", infix:true , index:true},
  
         ],
         "default_sorting_field": ""
       }'
       
curl "<http://localhost:8108/collections/companies/documents/import?action=create>" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -H "Content-Type: text/plain" \
        -X POST \
        -d '{"id": "1","handle": "23456789"}
            {"id": "2","handle": "9172837237"}'
            
curl "<http://localhost:8108/multi_search>" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -d '{
          "searches": [
            {
              "collection": "numbers",
              "q": "123456789",
              "query_by": "handle"
            }
          ]
        }'
k
I took a look into this and we can certainly support this. I'm going to try a few approaches now and figure out the optimized way to achieve this. Will keep you posted.
👍 1
d
How’s it going? U don’t have to go crazy on it, algolia only allows 1-2 typos on prefix
k
Almost there. Writing tests, will clean up, merge and share a build in a day or so.
d
Sounds good, I will deploy tomorrow night then :)
k
Hi Daren, I'm done with the changes and I have a build ready for you. Since we are in code freeze for v0.25 release and 0.26 has other unrelated changes, I created a build just with this change on the 0.25 RC branch that we have. Let me know how you deploy Typesense and I can share the build with you.
d
I’m running it locally on home brew, for production I can see version 0.25.0rc43 in the cloud console. I’d like to test it locally
brew install typesense/tap/typesense-server@ 0.25.0.rc43 Or something like that
Hi
j
We typically don’t publish RC builds for mac…
Would you be able to test via Docker?
d
Sure
Btw I’m using type sense cloud on production rc43 is the correct one right
j
This particular feature is on
0.25.0.rct46
- this is a build that we would have to upgrade you to from our side. Would you like us to do that?
d
I’d like to test locally before I do anything
Where to get the docker image
j
The docker tag is
typesense/typesense:0.25.0.rct46
👍 1
d
Working on my end. Will let you know when I’m deployed
j
Great! Let me know when you’d like to upgrade your cloud cluster to this build.