I just ran that snippet and it seems to work for m...
# community-help
j
I just ran that snippet and it seems to work for me:
Copy code
➜  ~ curl "<http://localhost:8108/collections>" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
       -d '{
         "name": "user",
         "fields": [
           {"name": "username", "type": "string" },
           {"name": "db_id", "type": "string" }
         ],
         "default_sorting_field": ""
       }'
{"created_at":1684166226,"default_sorting_field":"","enable_nested_fields":false,"fields":[{"facet":false,"index":true,"infix":false,"locale":"","name":"username","optional":false,"sort":false,"type":"string"},{"facet":false,"index":true,"infix":false,"locale":"","name":"db_id","optional":false,"sort":false,"type":"string"}],"name":"user","num_documents":0,"symbols_to_index":[],"token_separators":[]}%
➜  ~ curl "<http://localhost:8108/collections/user/documents/import?action=create>" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -H "Content-Type: text/plain" \
        -X POST \
        -d '{"id": "1","username": "UserTest","db_id": "1"}
            {"id": "2","username": "UserTest1","db_id": "2"}'
{"success":true}
{"success":true}%
➜  ~ curl "<http://localhost:8108/multi_search>" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -d '{
          "searches": [
            {
              "collection": "user",
              "q": "UserTest",
              "query_by": "username,db_id"
            }
          ]
        }' | jq
{
  "results": [
    {
      "facet_counts": [],
      "found": 2,
      "hits": [
        {
          "document": {
            "db_id": "1",
            "id": "1",
            "username": "UserTest"
          },
          "highlight": {
            "username": {
              "matched_tokens": [
                "UserTest"
              ],
              "snippet": "<mark>UserTest</mark>"
            }
          },
          "highlights": [
            {
              "field": "username",
              "matched_tokens": [
                "UserTest"
              ],
              "snippet": "<mark>UserTest</mark>"
            }
          ],
          "text_match": 578730123365712000,
          "text_match_info": {
            "best_field_score": "1108091339008",
            "best_field_weight": 15,
            "fields_matched": 1,
            "score": "578730123365711993",
            "tokens_matched": 1
          }
        },
        {
          "document": {
            "db_id": "2",
            "id": "2",
            "username": "UserTest1"
          },
          "highlight": {
            "username": {
              "matched_tokens": [
                "UserTest"
              ],
              "snippet": "<mark>UserTest</mark>1"
            }
          },
          "highlights": [
            {
              "field": "username",
              "matched_tokens": [
                "UserTest"
              ],
              "snippet": "<mark>UserTest</mark>1"
            }
          ],
          "text_match": 578730089005449300,
          "text_match_info": {
            "best_field_score": "1108074561536",
            "best_field_weight": 15,
            "fields_matched": 1,
            "score": "578730089005449337",
            "tokens_matched": 1
          }
        }
      ],
      "out_of": 2,
      "page": 1,
      "request_params": {
        "collection_name": "user",
        "per_page": 10,
        "q": "UserTest"
      },
      "search_cutoff": false,
      "search_time_ms": 2
    }
  ]
}