AppleBud
AppleBud

Reputation: 1541

Unable to delete unique document from Solr

I am trying to delete a document from Solr using deleteByQuery. The issue I am getting is that whenever I am trying to delete the document uniquely using only id, it is working fine.

However, when I am trying to delete based on more than one attribute, it is deleting all the documents where it finds even one attribute.

For eg,

if I have two documents say :

{
        "id": "232",
        "Author": "DEFG",
        "Name": "Alphabet",
        "Description": "Franz jagt im komplett verwahrlosten Taxi quer durch Bayern",
        "_version_": 1513077984291979300
      },
      {
        "id": "231",
        "Author": "ABCD",
        "Name": "Alphabet",
        "Description": "Franz jagt im komplett verwahrlosten Taxi quer durch Bayern",
        "_version_": 1513077999721775000
      }

and I want to delete the document where id is 231 and Author is "ABCD", I wrote this query to delete that particular document.

    $id=231;
    $author= "ABCD";

    $client->deleteByQuery("id:$id, Author:$author");
    $client->commit();

It is deleting both the documents with id 231 and id 232 rather than deleting only one.

Can anyone please resolve this issue or give me any solution so that I can achieve this?

Thanks.

Upvotes: 0

Views: 98

Answers (1)

Alexandre Rafalovitch
Alexandre Rafalovitch

Reputation: 9789

The delete query uses the same syntax as a search query. So you can easily test that query and tune it until it works. In your case, I suspect just doing id:$id AND Author:$author should work.

Upvotes: 2

Related Questions