mercredi 12 février 2020

Error in using Solr to add data - Solr HTTP error: OK (409)(HttpException )

I am trying this out for quite a time now, I have even googled a lot.

I am getting this error while trying to add data into Solr using Solarium in Laravel,

(1/1) HttpException

Solr HTTP error: OK (409)
{
"responseHeader":{
"status":409,
"QTime":3},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"version conflict for 12 expected=12435421423451 actual=-1",
"code":409}}
in Result.php line 106
at Result->__construct(object(Client), object(Query), object(Response))in Client.php line 753

This is my function in EmployeeController.php

public function enterDataSolr()
{

    $update = $this->client->createUpdate();


    $doc1 = $update->createDocument();
    $doc1->Gender = "M";
    $doc1->Salary = 199999;
    $doc1->SSN = "0050-03-10T21:00:00Z";
    $doc1->City = "Mumbai";
    $doc1->State = "Maharastra";
    $doc1->Zip = 119973;
    $doc1->Region = "Navi Mumbai";
    $doc1->Password = "21435t34tgsd";
    $doc1->id = 12;
    $doc1->_Emp_ID = 1234546;
    $doc1->Name_Prefix = "Mr.";
    $doc1->First_Name = "Kant";
    $doc1->Middle_Initial = "S";
    $doc1->Last_Name = "Bhat";
    $doc1->E_Mail = "nav@gmail.com";
    $doc1->Father_s_Name = "Mant";
    $doc1->Mother_s_Name = "Vandana";
    $doc1->Mother_s_Maiden_Name = "vandana";
    $doc1->Date_of_Birth = 12/2/1998;
    $doc1->Time_of_Birth = "12:24";
    $doc1->Age_in_Yrs = 21;
    $doc1->Weight_in_Kgs = 56;
    $doc1->Date_of_Joining = "2/2/2020";
    $doc1->Quarter_of_Joining = "Q1";
    $doc1->Half_of_Joining = "1st";
    $doc1->Year_of_Joining = 2020;
    $doc1->Month_of_Joining = 2;
    $doc1->Month_Name_of_Joining = "February";
    $doc1->Short_Month = "Feb";
    $doc1->Day_of_Joining = 2;
    $doc1->DOW_of_Joining = "Tuesday";
    $doc1->Short_DOW = "Tues";
    $doc1->Age_in_Company__Years_ = 2.4;
    $doc1->Last___Hike = 2;
    $doc1->Phone_No = 8906986022;
    $doc1->Place_Name = "Delhi";
    $doc1->User_Name = "kant";
    $doc1->_version_ = 12435421423451;
    $doc1->score = 1;

    $doc2 = $update->createDocument();
    $doc2->Gender = "F";
    $doc2->Salary = '200000';
    $doc2->SSN = "0050-03-10T00:00:00Z";
    $doc2->City = "Purcellville";
    $doc2->State = "VA";
    $doc2->Zip = 20134;
    $doc2->Region = "South";
    $doc2->Password = "1";
    $doc2->id = "2a69b460-2299-46a6-84b6-cf16938a1997";
    $doc2->_Emp_ID = 520092;
    $doc2->Name_Prefix = "Mrs.";
    $doc2->First_Name = "Mary";
    $doc2->Middle_Initial = "Watson";
    $doc2->Last_Name = "Jane";
    $doc2->E_Mail = "janemarie@hotmail.com";
    $doc2->Father_s_Name = "Spder";
    $doc2->Mother_s_Name = "May";
    $doc2->Mother_s_Maiden_Name = "may";
    $doc2->Date_of_Birth = "10/1/1921";
    $doc2->Time_of_Birth = "12:02";
    $doc2->Age_in_Yrs = 99;
    $doc2->Weight_in_Kgs = 61;
    $doc2->Date_of_Joining = "2/27/2020";
    $doc2->Quarter_of_Joining = "Q2";
    $doc2->Half_of_Joining = "Q1";
    $doc2->Year_of_Joining = "Q4";
    $doc2->Month_of_Joining = "2";
    $doc2->Month_Name_of_Joining = "February";
    $doc2->Short_Month = "Feb";
    $doc2->Day_of_Joining = 27;
    $doc2->DOW_of_Joining = "Tuesday";
    $doc2->Short_DOW = "Tues";
    $doc2->Age_in_Company__Years_ = 1.7;
    $doc2->Last___Hike = "11%";
    $doc2->Phone_No = 852489628962;
    $doc2->Place_Name = "Purcellville";
    $doc2->User_Name = "llwoods";
    $doc2->_version_ = 1658322049611851997;
    $doc2->score = 1;

    $update->addDocuments(array($doc1, $doc2));
    $update->addCommit();
    $result = $this->client->update($update); 

    echo '<b>Update query executed</b><br/>';
    echo 'Query status: ' . $result->getStatus(). '<br/>';
    echo 'Query time: ' . $result->getQueryTime();

}

The connection is made properly as as ping() function is returning status OK. The search function is working properly as well. This is the constructor

 public function __construct(EmployeeRepository $emp_repository, Client $client)
{   
    $this->emp_repository = $emp_repository;
    $this->client = $client;
    //dd('Solarium library version: ' . Client::VERSION . ' - ');

}

and I have used class as well

use Solarium\Client;


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/38jEa2o
via IFTTT

Aucun commentaire:

Enregistrer un commentaire