include_once("credential.php");
function delete_field($id,$del)
{
//echo "m here ".$query." m too ".$del."
";
date_default_timezone_set("Asia/Calcutta");
require_once('../SolrPhpClient/Apache/Solr/Service.php');
$solr = new Apache_Solr_Service($credential_arr['ip'],$credential_arr['port'],'/event/event');
//echo "m in function";exit;
$pairss = explode(',',$del);
//$str_arr1 = array("description","metroName");
$compulsory_str_field_arr = array("id","name","venue","startDate","endDate","time","categories","tags","categoryIds",
"catIdNames","startDay","endDay","address","photoFilePath","burrpPick","description","url","suggestionIds",
"suggestions","establishmentId","status","createdBy","createdOn","venueUrl","latitude","longitude","eventImages",
"neighbourhood","neighbourhoodIds","parentNeighbourhood","cityName","cityId","zoneId","zoneName","metroId",
"metroName","containsMessage","usersvisited","daysOfWeek","specialId","entityId","sponsoredWeight","voteFor",
"voteAgainst","pickOfTheDayDate","pickOfTheDayImage");
//print_r($compulsory_str_field_arr);exit;
//print_r($pairss);exit;
foreach($pairss as $k)
{
if(in_array($k,$compulsory_str_field_arr))
{
echo " can not delete ".$k."
";
$flg = 1;
}
}
if($flg==1)
{
exit;
}
array_push($pairss,"sdescription");
array_push($pairss,"smetroName");
$query = "id:".$id;
//print_r($pairss);
if($solr->ping())
{
//echo "m toooooo
";
echo $query."
";
$result1 = $solr->search($query);
if($result1->response->numFound > 0)
{
//echo "m inside ";exit;
$document = new Apache_Solr_Document();
$flag = 0;
foreach($result->response->docs as $doc)
{
foreach($doc as $key => $value)
{
if(!in_array($key,$pairss))
{
echo "if m here : ".$key."
";
$document->$key = $value;
$flag = 1;
}else
{
echo "else m here : ".$key."
";
}
}
//print_r($document);//exit;
if($flag ==1)
{
$solr->addDocument($document);
$solr->commit();
}
}
}
unset($solr);
}
else
{
echo "Solr Servers are not responding!";
}
}
?>