This message was deleted.
# community-help
s
This message was deleted.
j
Could you share a curl request with all the search parameters, minus the API key?
Side note: if there is a prefix match that will be ranked higher always, over an infix match
d
Copy code
curl 'https://mjxs6lrkh90e37y1p-1.a1.typesense.net/multi_search?x-typesense-api-key=API-KEY-HERE' \
  -H 'authority: mjxs6lrkh90e37y1p-1.a1.typesense.net' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: text/plain' \
  -H 'origin: http://localhost:3000' \
  -H 'referer: http://localhost:3000/' \
  -H 'sec-ch-ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' \
  --data-raw '{"searches":[{"query_by":"name,metadata.columns.name,sqlType,materializationType,locationName,database,schema,database_schema","infix":"always,off,off,off,off,off,off,off","highlight_full_fields":"name,metadata.columns.name,sqlType,materializationType,locationName,database,schema,database_schema","collection":"nodes","q":"ORDERS","facet_by":"sqlType,materializationType,database_schema,locationName","filter_by":"workspaceID:26","max_facet_values":10,"page":1,"per_page":100}]}' \
  --compressed
In regards to your side note, this was working previously, and I've had it return the correct results a few times, but 98% of the time I'm only getting one result. I'm searching for
ORDERS
, and it should match an item with the name
ORDERS
, as well as other items with prefixes or suffixes, such as
STG_ORDERS
or
PSTG_ORDERS_214
. But I'm only getting the exact match returned in my results.
j
I do see
OO_ORDERS
returned starting from the 4th result for that query:
Copy code
"highlight": {
            "name": {
              "matched_tokens": [
                "OO_ORDERS"
              ],
              "snippet": "markOO_ORDERS/mark",
              "value": "markOO_ORDERS/mark"
            }
          },
There's also
DELTA_OO_ORDERS
,
STG_ORDERS_COMPS
, etc
d
I'm using a scoped access key, as well as the filter on
workspaceID
to refine results to a single customer account. There should be two results that are returned based off of the query of `ORDERS`:
ORDERS
, and
STG_ORDERS
Behavior I'm seeing in app, just to show some examples of what's there by default, and what gets returned by my queries...
And when I run
Copy code
curl 'https://mjxs6lrkh90e37y1p-1.a1.typesense.net/multi_search?x-typesense-api-key=SCOPED_API_KEY_HERE' \
  -H 'authority: mjxs6lrkh90e37y1p-1.a1.typesense.net' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: text/plain' \
  -H 'origin: http://localhost:3000' \
  -H 'referer: http://localhost:3000/' \
  -H 'sec-ch-ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' \
  --data-raw '{"searches":[{"query_by":"name,metadata.columns.name,sqlType,materializationType,locationName,database,schema,database_schema","infix":"always,off,off,off,off,off,off,off","highlight_full_fields":"name,metadata.columns.name,sqlType,materializationType,locationName,database,schema,database_schema","collection":"nodes","q":"region","facet_by":"sqlType,materializationType,database_schema,locationName","filter_by":"workspaceID:26","max_facet_values":10,"page":1,"per_page":100}]}' \
  --compressed
with the scoped API key, I get
Copy code
{"results":[{"facet_counts":[{"counts":[{"count":1,"highlighted":"Source","value":"Source"}],"field_name":"sqlType","sampled":false,"stats":{"total_values":1}},{"counts":[{"count":1,"highlighted":"","value":""}],"field_name":"materializationType","sampled":false,"stats":{"total_values":1}},{"counts":[{"count":1,"highlighted":"COALESCE_SAMPLE_DATABASE.TPCH_SF001","value":"COALESCE_SAMPLE_DATABASE.TPCH_SF001"}],"field_name":"database_schema","sampled":false,"stats":{"total_values":1}},{"counts":[{"count":1,"highlighted":"SRC","value":"SRC"}],"field_name":"locationName","sampled":false,"stats":{"total_values":1}}],"found":1,"hits":[{"document":{"database":"COALESCE_SAMPLE_DATABASE","database_schema":"COALESCE_SAMPLE_DATABASE.TPCH_SF001","firestoreID":"ccdeba98-accc-4cc5-8fae-9b49ea70a816","id":"orgs/2G09yal084Jq7AYKaoxz/workspaces/26/steps/ccdeba98-accc-4cc5-8fae-9b49ea70a816","locationName":"SRC","materializationType":"","metadata":[[[[],["fcb4a9df-f070-4e7d-bf68-0dcfaedffcc1","ccdeba98-accc-4cc5-8fae-9b49ea70a816"],false,"","NUMBER(38,0)",false,"R_REGIONKEY","",[],[true,[]],false],[[],["fd58bbb5-9682-4061-aad6-4782cd86c4d2","ccdeba98-accc-4cc5-8fae-9b49ea70a816"],false,"",false,"VARCHAR(25)","R_NAME","",[],false,[true,[]]],[[],["c3a0b955-2db9-4758-9eb3-3136f412be71","ccdeba98-accc-4cc5-8fae-9b49ea70a816"],true,"","VARCHAR(152)",false,"R_COMMENT","",[],false,[true,[]]]],["FROM {{ ref('SRC', 'REGION') }}"]],"name":"REGION","orgID":"2G09yal084Jq7AYKaoxz","schema":"TPCH_SF001","sqlType":"Source","workspaceID":"26"},"highlight":{"name":{"matched_tokens":["REGION"],"snippet":"<mark>REGION</mark>","value":"<mark>REGION</mark>"}},"highlights":[{"field":"name","matched_tokens":["REGION"],"snippet":"<mark>REGION</mark>","value":"<mark>REGION</mark>"}],"text_match":578730123365711993,"text_match_info":{"best_field_score":"1108091339008","best_field_weight":15,"fields_matched":1,"score":"578730123365711993","tokens_matched":1}}],"out_of":438164,"page":1,"request_params":{"collection_name":"nodes-2023-08-11","per_page":100,"q":"region"},"search_cutoff":false,"search_time_ms":17}]}%
returned
j
Could you share the filter that's embedded in the scoped API key?
d
Copy code
const typesenseKey = client.keys().generateScopedSearchKey(typesenseSearchKey, {
    filter_by: `orgID:${request.params.orgID}`,
    expires_at: expirationDateSeconds,
  });
And in my case, orgID is
9oFpuSA9ozt55hxy6ByF
and my workspaceID is in the cURL, but it's
26
j
I converted that to a regular filter, but it's returning 0 results:
Copy code
"filter_by": "workspaceID:26 && orgID:9oFpuSA9ozt55hxy6ByF",
"q": "*"
even with q=*
is that the correct workspaceID / orgID?
d
Oh whoops, I sent the orgID for the wrong environment. Sorry about that, the correct orgID is
2G09yal084Jq7AYKaoxz
j
I do see infix matches returned for this query:
Copy code
$ curl -s "https://mjxs6lrkh90e37y1p-1.a1.typesense.net/multi_search?x-typesense-api-key=${TYPESENSE_API_KEY}" \
  --data-raw '
{
  "searches": [
    {
      "query_by": "name,metadata.columns.name,sqlType,materializationType,locationName,database,schema,database_schema",
      "infix": "always,off,off,off,off,off,off,off",
      "highlight_full_fields": "name,metadata.columns.name,sqlType,materializationType,locationName,database,schema,database_schema",
      "collection": "nodes",
      "q": "ORDERS",
      "facet_by": "sqlType,materializationType,database_schema,locationName",
      "filter_by": "workspaceID:26 && orgID:2G09yal084Jq7AYKaoxz",
      "max_facet_values": 10,
      "page": 1,
      "per_page": 100
    }
  ]
}
' | jq '.results[0].hits[].document.name'
"ORDERS"
"STG_ORDERS"
If I do
q=*
I get the following:
Copy code
"STG_ORDERS"
"STG_REGION"
"SUPPLIER"
"REGION"
"PARTSUPP"
"NATION"
"ORDERS"
"PART"
"CUSTOMER"
"DAILY_14_TOTAL_SHORT"
"LINEITEM"
"STG_CUSTOMER"
d
I'm seeing that too now... But when I recorded that video 10 min ago, I was only getting the one result for
ORDERS
. Now on my end, it's working for
ORDERS
and
CUSTOMERS,
but not for
REGION
.
I'm not sure what would have caused the behavior to change in the last few minutes, but it's still not behaving 100% as expected.
j
Hmmm yeah, I see the issue with
REGION
now
d
Now
REGION
is working if the query is upper case, and not working if it's lower case
j
Restarting your node to see if this is some memory corruption issue
✅ 1
I saw the flipping issue happen as I was trying out the same curl commands after the restart
I then noticed that there is a regular stream of document deletes and creation happening in parallel
Could it be possible that this document is being repeatedly deleted and recreated somehow that's causing the results to flip?
d
That doesn’t sound likely to me…. The original document is in FireStore, and it isn’t being deleted / recreated at all. It’s possible our google cloud function is doing something weird, but that also doesn’t seem likely to me… 🤔
j
We'd need to take a closer look at this with a debug build. Would you be ok if we loaded the data from your cluster into an internal debug build? We'll be sure to delete the data once we finish debugging the issue
d
That is fine with me, I appreciate the help and quick responses as always 🙌
👍 1
j
Cool I'll keep you posted
Btw, on a side note, do your infix search words always have a preceding
_
character?
d
Much of the time they will, yes.
j
You might want to consider setting
_
as a
token_separator
when creating the collection schema in that case. Then you won't need to use infix search
d
I have these in my schema, is it an issue that these symbols are under both of these keys?
Copy code
"symbols_to_index": [
    "_",
    "-",
    "."
  ],
  "token_separators": [
    "_",
    "-",
    "."
  ]
j
Essentially that will get Typesense to index
STG_ORDER
as
STG
and
ORDER
(as two separate words) and regular prefix search will then work
👍 1
Oh hmm, then you already shouldn't have to specify infix
d
Hmm, that's interesting. I can try it without the
additionalSearchParameters
for
infix
j
You want to remove
symbols_to_index
from the collection though
symbols_to_index
takes precedence over
token_separators
d
Gotcha, I'll give that a shot
Is it possible to do that without having to create a brand new collection?
j
Unfortunately no
That setting can only be set when creating a collection, since it involves reindexing the data internally
👍 1
@David Engel Would you be able to trigger a couple of writes on your cluster to this collection?
The issue seems to be non deterministic, so we're trying to figure out what set of conditions trigger the issue
CC: @Kishore Nallan
d
Sure thing, I’ll trigger some writes now, and let me know if you’d like for me to trigger more.
j
Could you confirm the timestamp when you triggered the writes? Is it within 5 minutes of when you posted the message above?
d
Maybe just over 5 minutes from when I posted the message. 12 minutes ago at around 10:11AM mountain standard time
👍 1
Following up on this thread @Jason Bosco - were you ever able to reproduce reliably?
j
Had it on my todo list to follow up with you. We unfortunately were not able to reproduce it consistently... But we've added a potential fix that might cause this issue. But not too confident if that's the root cause... Could you upgrade your cluster to 0.25.2.rc6, and then trigger a few writes like last time?
d
Okay, thank you! & sure, I'll upgrade the cluster now.
j
Could you let me know once you've upgraded and triggered the writes?
d
Cluster upgraded - and I'm not seeing the issue anymore 🤞 But it's been a bit sporadic in the past. & I just triggered some writes
j
🤞 😅
d
Well unfortunately some other members of my team are still seeing the issue in their environments 😞
And suddenly, I'm seeing it in my environment again too.
j
Yup, I see it on your cluster too... Ok, next step, we're going to run a debug build of Typesense directly on your cluster with detailed tracing, so we can figure out where things go wrong directly in your environment. I'll keep you posted.
d
Excellent, thanks Jason
👍 1
Just a heads up, we're changing our schema to implement your suggestion with
token_separators
and that appears to be successful so far
j
That's good to hear! I guess that side-steps the other issue. Btw, the cluster ID you shared with me earlier in this thread, is that a staging cluster? Is it ok if we have to restart it a couple of times to narrow down the other issue
d
That was a dev cluster actually, our staging cluster is
l2cioyjbxrn89hqkp-1.a1.typesense.net
and probably won't be updated for 1-3 days. You're free to restart as needed
j
Got it, thank you
@David Engel I have a debug build ready to test with. I noticed on the cluster you shared above that the token_separator setting has already been setup. Would you be able to setup a new collection on that cluster with the old schema and old dataset to replicate the other issue?
d
@Jason Bosco sure thing, I can put that together today. I'll send some info your way once it's complete.
🙏 1
@Jason Bosco Done. The new collection is
nodes-typesense-test
on cluster
mjxs6lrkh90e37y1p-1.a1.typesense.net
. I didn't deploy a firestore cloud function for this collection, because I don't think that's related to the bug, but the schema and data is identical to the original collection we were troubleshooting.
We're still experiencing some inconsistency with
infix
search after the schema updates were made to our clusters. •
symbols_to_index: []
is empty so it doesn't overwrite
token_separators: ["_", "-", "."]
• We have
infix: true
on the field we want to enable infix search on, and that same field has
infix: always
in our
additionalSearchParameters
But we're still getting inconsistent results. For example: • searching for
item
should return
lineitem
and
stg_lineitem
, but it returns no results. • searching for
otal
should return
daily_14_total_short
and
stg_daily_total_short
, but it returns no results. These results are returned if I search for
ort
instead. • searching for
ppli
returns
supplier
, &
stg_supplier
when I would expect it to return nothing after running the previous two queries We do want the infix search results returned, like in the third example, or the
ort
query in the second bullet note. Not too sure what else I can do to make the results more consistent
j
searching for item should return lineitem and stg_lineitem, but it returns no results.
Could you give me a full curl request that replicates this issue? I just tried it with this and it seems to work:
Copy code
curl -sk "https://mjxs6lrkh90e37y1p-1.a1.typesense.net/multi_search?x-typesense-api-key=${TYPESENSE_API_KEY}" \
  --data-raw '
{
  "searches": [
    {
      "query_by": "name,metadata.columns.name,sqlType,materializationType,locationName,database,schema,database_schema",
      "infix": "always,off,off,off,off,off,off,off",
      "highlight_full_fields": "name,metadata.columns.name,sqlType,materializationType,locationName,database,schema,database_schema",
      "collection": "nodes-typesense-test",
      "q": "item",
      "facet_by": "sqlType,materializationType,database_schema,locationName",
      "filter_by": "workspaceID:26",
      "max_facet_values": 10,
      "page": 1,
      "per_page": 100
    }
  ]
}
' | jq '.results[0].hits[].document.name'
d
Copy code
curl 'https://mjxs6lrkh90e37y1p-1.a1.typesense.net/multi_search?x-typesense-api-key=TYPESENSE_API_KEY' \
  -H 'authority: mjxs6lrkh90e37y1p-1.a1.typesense.net' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: text/plain' \
  -H 'origin: https://dev.app.coalescestage.io' \
  -H 'referer: https://dev.app.coalescestage.io/' \
  -H 'sec-ch-ua: "Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36' \
  --data-raw '{"searches":[{"query_by":"name,sqlType,materializationType,locationName,database,schema,database_schema","infix":"always,off,off,off,off,off,off","highlight_full_fields":"name,sqlType,materializationType,locationName,database,schema,database_schema","collection":"nodes","q":"item","facet_by":"sqlType,materializationType,database_schema,locationName","filter_by":"workspaceID:25","max_facet_values":10,"page":1,"per_page":100}]}' \
this is also using the scoped access key
Copy code
client.keys().generateScopedSearchKey(typesenseSearchKey, {
    filter_by: `orgID:2G09yal084Jq7AYKaoxz`,
    expires_at: <expiration-date>,
  });
And then filtering on
workspaceID: 25
like previously.
j
This seems to work for me:
Copy code
$ curl -s "https://mjxs6lrkh90e37y1p-1.a1.typesense.net/multi_search?x-typesense-api-key=${TYPESENSE_API_KEY}" \
  --data-raw '
{
  "searches": [
    {
      "query_by": "name,sqlType,materializationType,locationName,database,schema,database_schema",
      "infix": "always,off,off,off,off,off,off",
      "highlight_full_fields": "name,sqlType,materializationType,locationName,database,schema,database_schema",
      "collection": "nodes",
      "q": "item",
      "facet_by": "sqlType,materializationType,database_schema,locationName",
      "filter_by": "workspaceID:25",
      "max_facet_values": 10,
      "page": 1,
      "per_page": 20
    }
  ]
}' | jq '.results[0].hits[].document.name'
"ITEM"
"ITEM"
"PSTG_CW_IV_ITEM"
"STG_CW_IV_ITEM"
"LINE_ITEM"
"PSTG_QBO_ITEM"
"STG_QBO_ITEM"
"IV_ITEM"
"PROCESSING_SITE_SHIFT_ITEM"
"IV_ITEM"
"STAGE_VISIT_CLINICITEM"
"STAGE_CLINICITEM"
"S_CLINICITEM_LROC_INFO_CURRENT"
"S_INVOICE_CLINICITEM_LROC_INFO"
"S_VISIT_CLINICITEM_LROC_INFO"
"L_MANUFACTURER_CLINICITEM"
"L_VISIT_CLINICITEM"
"S_VISIT_CLINICITEM_LROC_INFO_CURRENT"
"S_CLINICITEM_LROC_INFO_PIT"
"S_VISIT_CLINICITEM_LROC_INFO_PIT"
d
Hmm yeah, now that is working for me as well... Seems to be the same issue as previously.
searching for
otal
should return
daily_14_total_short
and
stg_daily_total_short
is also working. But
searching for
ppli
returns
supplier
, &
stg_supplier
did work previously, and now it's not.
Copy code
curl 'https://mjxs6lrkh90e37y1p-1.a1.typesense.net/multi_search?x-typesense-api-key=TYPESENSE_API_KEY' \
  -H 'authority: mjxs6lrkh90e37y1p-1.a1.typesense.net' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: text/plain' \
  -H 'origin: https://dev.app.coalescestage.io' \
  -H 'referer: https://dev.app.coalescestage.io/' \
  -H 'sec-ch-ua: "Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36' \
  --data-raw '{"searches":[{"query_by":"name,sqlType,materializationType,locationName,database,schema,database_schema","infix":"always,off,off,off,off,off,off","highlight_full_fields":"name,sqlType,materializationType,locationName,database,schema,database_schema","collection":"nodes","q":"ppli","facet_by":"sqlType,materializationType,database_schema,locationName","filter_by":"workspaceID:25","max_facet_values":10,"page":1,"per_page":100}]}' \
  --compressed
returns
Copy code
{
  "results": [
    {
      "facet_counts": [
        {
          "counts": [],
          "field_name": "sqlType",
          "sampled": false,
          "stats": {
            "total_values": 0
          }
        },
        {
          "counts": [],
          "field_name": "materializationType",
          "sampled": false,
          "stats": {
            "total_values": 0
          }
        },
        {
          "counts": [],
          "field_name": "database_schema",
          "sampled": false,
          "stats": {
            "total_values": 0
          }
        },
        {
          "counts": [],
          "field_name": "locationName",
          "sampled": false,
          "stats": {
            "total_values": 0
          }
        }
      ],
      "found": 0,
      "hits": [],
      "out_of": 479577,
      "page": 1,
      "request_params": {
        "collection_name": "nodes-2023-10-23",
        "per_page": 100,
        "q": "ppli"
      },
      "search_cutoff": false,
      "search_time_ms": 7
    }
  ]
}
Sorry, this is a tricky one
& now the
item
query isn't returning anything again
j
Yup I see these issues now
👍 1
Trying to debug it
✅ 1
Could you trigger some writes on this collection?
d
Yep, one moment.
think I triggered some, experiencing some other strange behavior so I can't verify at the moment
Will confirm as soon as I can
yeah, they went through
👍 1
j
experiencing some other strange behavior
Might because of us restarting the process while we were debugging.
👍 1
Continuing to debug
Finally replicated the issue consistently in our debug env! We’re working on a fix.
d
That’s great to hear! And much appreciated 🙌
j
@David Engel Could you upgrade to
0.26.0.rc29
and try to replicate the issue? Some refactoring we did to fix other bugs seems to have also addressed this issue as a side effect in that build, at least in our tests
d
Will do! I'll update here in a bit.
0.26.0.rc29
does appear a bit better, but still not getting some expected results. > searching for
otal
should return
daily_14_total_short
and
stg_daily_total_short
is currently working > searching for
ppli
returns
supplier
, &
stg_supplier
worked the first time I tried, but now it's not returning any results > searching for
item
should return
lineitem
and
stg_lineitem
, and
stg_lineitem1
is returning
STG_LINEITEM1
, but not
LINEITEM
or
STG_LINEITEM
j
Hmmm ok 😞 Will continue debugging
🙏 1
@David Engel We were finally able to get to the root cause of the issue. We've patched your cluster with
0.26.0.rc32
. Could you confirm if everything looks good now?
d
@Jason Bosco Everything looks good from initial testing! All my example queries from above are working so far. Will continue testing and will tell my team to do the same. Thanks for your help with this! 🙌
j
Awesome! Could you also try triggering a couple of writes and testing it again?
Thank you for helping get to the bottom of this issue!
🎉 1
d
Of course! And the new writes are looking good as well. Only thing I notice is that
infix
hits don't seem to highlight the relevant part of the title, but rather the full word. It was like this previously, and isn't a big deal to us at the moment!
j
Yeah, that's a known issue - infix search results only have word-level highlighting at the moment. There's an open GitHub issue for it here. Could you add a thumbs-up to it?
✅ 1
🙌 1
d
Sounds good! Lastly, is there an ETA for when
v0.26.0.rc32
will be officially released? My team is hesitant to take this to prod until it's publicly available.
j
It's going to be at least another month, if not Jan next year before we'd want to do a GA release for
0.26.0
... But usually most RC builds are safe to run on production and many of our users do this. We also tend to patch known issues quickly on these RC builds as they are reported. The last GA build is essentially just the promotion of the last RC build after we've fixed all known issues and nothing has been reported for a few weeks.
d
Okay, I'll relay that info. Thanks very much!
👍 1