Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documents with duplicate IDs #15

Closed
jasonbosco opened this issue Jan 20, 2018 · 4 comments
Closed

Documents with duplicate IDs #15

jasonbosco opened this issue Jan 20, 2018 · 4 comments
Assignees
Labels

Comments

@jasonbosco
Copy link
Member

Description

Looks like currently you can create multiple documents with the same ID. Was this intended?

Then when you try to retrieve a document (with duplicate IDs), only the last document is returned. Although the search endpoint retrieves all the documents.

Steps to reproduce

$ curl "${TYPESENSE_HOST}/collections" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
       -d '{
             "name": "companies",
             "fields": [
               {"name": "company_name", "type": "string" },
               {"name": "num_employees", "type": "int32" },
               {"name": "country", "type": "string", "facet": true }
             ],
             "token_ranking_field": "num_employees"
          }' 

{
  "name": "companies",
  "num_documents": 0,
  "fields": [
    {"name": "company_name", "type": "string" },
    {"name": "num_employees", "type": "int32" },
    {"name": "country", "type": "string", "facet": true }
  ],
  "token_ranking_field": "num_employees"
}

$ curl "${TYPESENSE_HOST}/collections/companies/documents" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
       -d '{
            "id": "124",
            "company_name": "Stark Industries",
            "num_employees": 5215,
            "country": "USA"
          }'

{
  "id": "124",
  "company_name": "Stark Industries",
  "num_employees": 5215,
  "country": "USA"
}

$ curl "${TYPESENSE_HOST}/collections/companies/documents" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
       -d '{
            "id": "124",
            "company_name": "Stark Industries",
            "num_employees": 5215,
            "country": "USA"
          }'

{
  "id": "124",
  "company_name": "Stark Industries",
  "num_employees": 5215,
  "country": "USA"
}

Expected Behavior

May be error out when a document with the same ID already exists?

Actual Behavior

Allows documents with the same ID to be indexed.

Metadata

Typsense Version: 0.8.0

OS: Ubuntu inside Docker

@kishorenc
Copy link
Member

It's a bug. I will look into it.

@kishorenc kishorenc added the bug label Jan 21, 2018
@kishorenc kishorenc self-assigned this Jan 21, 2018
@kishorenc
Copy link
Member

@jasonbosco Fixed by 85f9887

I've republished the Docker image. Please verify and close this issue.

@kishorenc
Copy link
Member

Made one minor change. Returning 409 Conflict when the document ID already exists, which is consistent with the collections end-point.

@jasonbosco
Copy link
Member Author

Verified that it works 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants