Commit 86054c92 authored by André Antônio Lemos de Moraes's avatar André Antônio Lemos de Moraes Committed by Dorian Villet

Upgrade to beat the rule of solr ...

Example of "add" with optional update attribute to set a field to null (i.e. delete a field):

<add>
  <doc>
    <field name="employeeId">05991</field>
    <field name="skills" update="set" null="true" />
  </doc>
</add>
parent ea735246
...@@ -199,7 +199,7 @@ class Document extends AbstractDocument implements DocumentInterface ...@@ -199,7 +199,7 @@ class Document extends AbstractDocument implements DocumentInterface
*/ */
public function setField($key, $value, $boost = null, $modifier = null) public function setField($key, $value, $boost = null, $modifier = null)
{ {
if ($value === null) { if ($value === null && $modifier == null) {
$this->removeField($key); $this->removeField($key);
} else { } else {
$this->fields[$key] = $value; $this->fields[$key] = $value;
......
...@@ -169,6 +169,9 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -169,6 +169,9 @@ class RequestBuilder extends BaseRequestBuilder
$xml = '<field name="' . $name . '"'; $xml = '<field name="' . $name . '"';
$xml .= $this->attrib('boost', $boost); $xml .= $this->attrib('boost', $boost);
$xml .= $this->attrib('update', $modifier); $xml .= $this->attrib('update', $modifier);
if($value === null){
$xml .= $this->attrib('null', 'true');
}
$xml .= '>' . htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8'); $xml .= '>' . htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
$xml .= '</field>'; $xml .= '</field>';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment