Hi, I have a product collection given below. When ...
# community-help
m
Hi, I have a product collection given below. When I search for
Queen Remi Blue 12
I want the exact matched products to be ranked at the top. But, in the result it is ranking partial matched product
Queen Remi Blue Ow 12
at the top where
OW
doesn't exist in the search query. is it possible to achieve with Typesense? if so, how?
Copy code
[
      { id: '1', name: 'QUEEN REMI BLUE 12"#TUR' },
      { id: '2', name: 'QUEEN REMI BLUE 12"#T1BRD' },
      { id: '3', name: 'QUEEN REMI BLUE 12"#T1BBG' },
      { id: '4', name: 'QUEEN REMI BLUE 12"#T1B99J' },
      { id: '5', name: 'QUEEN REMI BLUE OW 12"#T1B350' },
      { id: '6', name: 'QUEEN REMI BLUE OW 12"#T1B30' },
      { id: '7', name: 'QUEEN REMI BLUE OW 12"#T1B27' },
      { id: '8', name: 'QUEEN REMI BLUE OW 12"#RED' },
      { id: '9', name: 'QUEEN REMI BLUE OW 12"#P4/30' },
    ];
k
Try with this flag:
Copy code
prioritize_token_position: true
m
@Kishore Nallan Thanks for your quick response. But this doesn't help
I have found that when I add the last
12
in the query, things get messed up
k
Please provide a reproducible example in this format: https://gist.github.com/jasonbosco/7c3432713216c378472f13e72246f46b
m
I have left my comment there. Please check if it works
k
No, can you please delete that comment and post a separate gist here?
m
Copy code
curl "<http://localhost:8108/collections>" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
       -d '{
         "name": "companies",
         "fields": [
           {"name": "name", "type": "string","index": true },
           {"name": "id", "type": "string" }
         ],
         "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","name": "QUEEN REMI BLUE OW 12\"#P430"}
              {"id": "2","name": "QUEEN REMI BLUE OW 12\"#613"}
              {"id": "3","name": "QUEEN REMI BLUE 12\"#TUR"}
              {"id": "4","name": "QUEEN REMI BLUE 12\"#613"}'
            
curl "<http://localhost:8108/multi_search>" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -d '{
          "searches": [
            {
              "collection": "companies",
              "q": "QUEEN REMI BLUE 12",
              "query_by": "name"
            }
          ]
        }'
Copy code
### Run Typesense via Docker ########################################
export TYPESENSE_API_KEY=xyz
    
mkdir "$(pwd)"/typesense-data

docker run -p 8108:8108 \
            -v"$(pwd)"/typesense-data:/data typesense/typesense:28.0 \
            --data-dir /data \
            --api-key=$TYPESENSE_API_KEY \
            --enable-cors

### Reproduction Steps ###############################################
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": "companies",
         "fields": [
           {"name": "name", "type": "string","index": true },
           {"name": "id", "type": "string" }
         ],
         "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","name": "QUEEN REMI BLUE OW 12\"#P430"}
              {"id": "2","name": "QUEEN REMI BLUE OW 12\"#613"}
              {"id": "3","name": "QUEEN REMI BLUE 12\"#TUR"}
              {"id": "4","name": "QUEEN REMI BLUE 12\"#613"}'
            
curl "<http://localhost:8108/multi_search>" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -d '{
          "searches": [
            {
              "collection": "companies",
              "q": "QUEEN REMI BLUE 12",
              "query_by": "name"
            }
          ]
        }'
@Kishore Nallan Please let me know if that works
k
When I run the command I get the exact matches first.
Copy code
"snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#613"
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#613"
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#TUR"
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#TUR"
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#613"
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#613"
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#P430"
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#P430"
m
@Kishore Nallan Can you try this one?
Copy code
### Run Typesense via Docker ########################################
export TYPESENSE_API_KEY=xyz
    
mkdir "$(pwd)"/typesense-data

docker run -p 8108:8108 \
            -v"$(pwd)"/typesense-data:/data typesense/typesense:28.0 \
            --data-dir /data \
            --api-key=$TYPESENSE_API_KEY \
            --enable-cors

### Reproduction Steps ###############################################
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": "companies",
         "fields": [
           {"name": "name", "type": "string","index": true },
           {"name": "id", "type": "string" }
         ],
         "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": "3","name": "QUEEN REMI BLUE 12\"#TUR"}
              {"id": "4","name": "QUEEN REMI BLUE 12\"#613"}
              {"id": "1","name": "QUEEN REMI BLUE OW 12\"#P430"}
              {"id": "2","name": "QUEEN REMI BLUE OW 12\"#613"}'
            
curl "<http://localhost:8108/multi_search>" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -d '{
          "searches": [
            {
              "collection": "companies",
              "q": "QUEEN REMI BLUE 12",
              "query_by": "name"
            }
          ]
        }'
k
Can you clearly post what you are getting for the command above and what you are expecting first?
m
I am trying to get the 2nd product first as it matches whole query exactly
I think typesense is ranking based on the insertion order
k
But that's not being reproduced in the test above. Without reproducible example, difficult to say what's going wrong.
m
Now I will send you another example which will give you the problematic result. Please try with this @Kishore Nallan
Copy code
### Run Typesense via Docker ########################################
export TYPESENSE_API_KEY=xyz
    
mkdir "$(pwd)"/typesense-data

docker run -p 8108:8108 \
            -v"$(pwd)"/typesense-data:/data typesense/typesense:28.0 \
            --data-dir /data \
            --api-key=$TYPESENSE_API_KEY \
            --enable-cors

### Reproduction Steps ###############################################
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": "companies",
         "fields": [
           {"name": "name", "type": "string","index": true },
           {"name": "id", "type": "string" }
         ],
         "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": "3","name": "QUEEN REMI BLUE 12\"#TUR"}
              {"id": "4","name": "QUEEN REMI BLUE 12\"#613"}
              {"id": "1","name": "QUEEN REMI BLUE OW 12\"#P430"}
              {"id": "2","name": "QUEEN REMI BLUE OW 12\"#613"}'
            
curl "<http://localhost:8108/multi_search>" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -d '{
          "searches": [
            {
              "collection": "companies",
              "q": "QUEEN REMI BLUE 12",
              "query_by": "name"
            }
          ]
        }'
k
Can you please post a screenshot of the results you are getting from the multi_search curl command above?
m
I don't have docker installed. I am testing with real data that mimics the test data I sent you
f
No need to use docker, you can use the bare metal instance of Typesense as well
m
Copy code
{
  "results": [
    {
      "facet_counts": [],
      "found": 6,
      "hits": [
        {
          "document": {
            "name": "QUEEN REMI BLUE OW 12\"#TADA"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW 12\"#TADA"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW 12\"#TADA"
            }
          ],
          "text_match": 1736172819517014000,
          "text_match_info": {
            "best_field_score": "3315704397824",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 1,
            "score": "1736172819517014137",
            "tokens_matched": 3,
            "typo_prefix_score": 0
          }
        },
        {
          "document": {
            "name": "QUEEN REMI BLUE OW 12\"#ERROR"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW 12\"#ERROR"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW 12\"#ERROR"
            }
          ],
          "text_match": 1736172819517014000,
          "text_match_info": {
            "best_field_score": "3315704397824",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 1,
            "score": "1736172819517014137",
            "tokens_matched": 3,
            "typo_prefix_score": 0
          }
        },
        {
          "document": {
            "name": "QUEEN REMI BLUE 12\"#6345"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> 12\"#6345"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> 12\"#6345"
            }
          ],
          "text_match": 1736172819517014000,
          "text_match_info": {
            "best_field_score": "3315704397824",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 1,
            "score": "1736172819517014137",
            "tokens_matched": 3,
            "typo_prefix_score": 0
          }
        },
        {
          "document": {
            "name": "QUEEN REMI BLUE 12\"#TUR"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> 12\"#TUR"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> 12\"#TUR"
            }
          ],
          "text_match": 1736172819517014000,
          "text_match_info": {
            "best_field_score": "3315704397824",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 1,
            "score": "1736172819517014137",
            "tokens_matched": 3,
            "typo_prefix_score": 0
          }
        },
        {
          "document": {
            "name": "QUEEN REMI BLUE OW 12\"#613"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW 12\"#613"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW 12\"#613"
            }
          ],
          "text_match": 1736172819517014000,
          "text_match_info": {
            "best_field_score": "3315704397824",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 1,
            "score": "1736172819517014137",
            "tokens_matched": 3,
            "typo_prefix_score": 0
          }
        },
        {
          "document": {
            "name": "QUEEN REMI BLUE OW 12\"#P430"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW 12\"#P430"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW 12\"#P430"
            }
          ],
          "text_match": 1736172819517014000,
          "text_match_info": {
            "best_field_score": "3315704397824",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 1,
            "score": "1736172819517014137",
            "tokens_matched": 3,
            "typo_prefix_score": 0
          }
        }
      ],
      "out_of": 176976,
      "page": 1,
      "request_params": {
        "collection_name": "rs-keymaster-products",
        "first_q": "QUEEN REMI BLUE 12",
        "per_page": 10,
        "q": "QUEEN REMI BLUE 12"
      },
      "search_cutoff": false,
      "search_time_ms": 7
    }
  ]
}
@Kishore Nallan This is the result I have got from the curl command.
k
Your script above inserts only 4 documents, but search shoes six documents. It's really difficult to help unless you share a proper reproducible example that you have verified once.
m
let me create a final snippet for you
Copy code
### Run Typesense via Docker ########################################
export TYPESENSE_API_KEY=xyz
    
mkdir "$(pwd)"/typesense-data

docker run -p 8108:8108 \
            -v"$(pwd)"/typesense-data:/data typesense/typesense:28.0 \
            --data-dir /data \
            --api-key=$TYPESENSE_API_KEY \
            --enable-cors

### Reproduction Steps ###############################################
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": "companies",
         "fields": [
           {"name": "name", "type": "string","index": true },
           {"name": "id", "type": "string" }
         ],
         "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": "3","name": "QUEEN REMI BLUE OW 12\"#P430"}
              {"id": "4","name": "QUEEN REMI BLUE OW 12\"#613"}
              {"id": "1","name": "QUEEN REMI BLUE 12\"#TUR"}
              {"id": "2","name": "QUEEN REMI BLUE 12\"#6345"}
              {"id": "5","name": "QUEEN REMI BLUE OW 12\"#ERROR"}
              {"id": "6","name": "QUEEN REMI BLUE OW 12\"#TADA"}'
            
curl "<http://localhost:8108/multi_search>" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -d '{
          "searches": [
            {
              "collection": "companies",
              "q": "QUEEN REMI BLUE 12",
              "query_by": "name"
            }
          ]
        }'
in the above example you will see that we are searching for
Queen Remi Blue 12
but it's ranking the names with
OW
first even if we have exact match @Kishore Nallan
k
When I run the example, I get the first hit to be the exact match.
Copy code
"<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#6345"
m
Can you share your whole search result?
k
First hit:
Copy code
{
          "document": {
            "id": "2",
            "name": "QUEEN REMI BLUE 12\"#6345"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#6345"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#6345"
            }
          ],
m
@Kishore Nallan Can you please drop the whole curl response here?
k
Copy code
{
  "results": [
    {
      "facet_counts": [],
      "found": 6,
      "hits": [
        {
          "document": {
            "id": "2",
            "name": "QUEEN REMI BLUE 12\"#6345"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#6345"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#6345"
            }
          ],
          "text_match": 2314894133233713000,
          "text_match_info": {
            "best_field_score": "4419494150400",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 0,
            "score": "2314894133233713273",
            "tokens_matched": 4,
            "typo_prefix_score": 1
          }
        },
        {
          "document": {
            "id": "1",
            "name": "QUEEN REMI BLUE 12\"#TUR"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#TUR"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> <mark>12</mark>\"#TUR"
            }
          ],
          "text_match": 2314894133233713000,
          "text_match_info": {
            "best_field_score": "4419494150400",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 0,
            "score": "2314894133233713273",
            "tokens_matched": 4,
            "typo_prefix_score": 1
          }
        },
        {
          "document": {
            "id": "6",
            "name": "QUEEN REMI BLUE OW 12\"#TADA"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#TADA"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#TADA"
            }
          ],
          "text_match": 2314894133098971000,
          "text_match_info": {
            "best_field_score": "4419494084608",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 0,
            "score": "2314894133098971257",
            "tokens_matched": 4,
            "typo_prefix_score": 1
          }
        },
        {
          "document": {
            "id": "5",
            "name": "QUEEN REMI BLUE OW 12\"#ERROR"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#ERROR"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#ERROR"
            }
          ],
          "text_match": 2314894133098971000,
          "text_match_info": {
            "best_field_score": "4419494084608",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 0,
            "score": "2314894133098971257",
            "tokens_matched": 4,
            "typo_prefix_score": 1
          }
        },
        {
          "document": {
            "id": "4",
            "name": "QUEEN REMI BLUE OW 12\"#613"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#613"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#613"
            }
          ],
          "text_match": 2314894133098971000,
          "text_match_info": {
            "best_field_score": "4419494084608",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 0,
            "score": "2314894133098971257",
            "tokens_matched": 4,
            "typo_prefix_score": 1
          }
        },
        {
          "document": {
            "id": "3",
            "name": "QUEEN REMI BLUE OW 12\"#P430"
          },
          "highlight": {
            "name": {
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#P430"
            }
          },
          "highlights": [
            {
              "field": "name",
              "matched_tokens": [
                "QUEEN",
                "REMI",
                "BLUE",
                "12"
              ],
              "snippet": "<mark>QUEEN</mark> <mark>REMI</mark> <mark>BLUE</mark> OW <mark>12</mark>\"#P430"
            }
          ],
          "text_match": 2314894133098971000,
          "text_match_info": {
            "best_field_score": "4419494084608",
            "best_field_weight": 15,
            "fields_matched": 1,
            "num_tokens_dropped": 0,
            "score": "2314894133098971257",
            "tokens_matched": 4,
            "typo_prefix_score": 1
          }
        }
      ],
      "out_of": 6,
      "page": 1,
      "request_params": {
        "collection_name": "companies",
        "first_q": "QUEEN REMI BLUE 12",
        "per_page": 10,
        "q": "QUEEN REMI BLUE 12"
      },
      "search_cutoff": false,
      "search_time_ms": 4
    }
  ]
}
m
@Kishore Nallan You are right. I am wondering why is it behaving different in the production. Can you help me if I share the production schema?
@Kishore Nallan The problem is reappearing. Hope you will be able to notice the issue this time. Here is my updated test case for you.
Copy code
### Run Typesense via Docker ########################################
export TYPESENSE_API_KEY=xyz
    
mkdir "$(pwd)"/typesense-data

docker run -p 8108:8108 \
            -v"$(pwd)"/typesense-data:/data typesense/typesense:28.0 \
            --data-dir /data \
            --api-key=$TYPESENSE_API_KEY \
            --enable-cors

### Reproduction Steps ###############################################
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": "companies",
         "fields": [
           {"name": "name", "type": "string","index": true },
           {"name": "id", "type": "string" }
         ],
         "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": "3","name": "QUEEN REMI BLUE OW 12\" #P430"}
              {"id": "4","name": "QUEEN REMI BLUE OW 12\" #613"}
              {"id": "1","name": "QUEEN REMI BLUE 12\"#TUR"}
              {"id": "2","name": "QUEEN REMI BLUE 12\"#6345"}'
            
curl "<http://localhost:8108/multi_search>" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -d '{
          "searches": [
            {
              "collection": "companies",
              "q": "QUEEN REMI BLUE 12",
              "query_by": "name"
            }
          ]
        }'
k
Sorry, but your reproducible example does not work. Unless you share the actual sample / dataset, I won't be able to help. We have to support a large number of customers: unless you can provide a clearly reproducible example, we only have limited time to spend.
👍 1