Skip to content

Commit

Permalink
Fix indexing of null values
Browse files Browse the repository at this point in the history
  • Loading branch information
reebalazs committed Jan 31, 2024
1 parent e70366c commit 43858be
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/collective/solr/solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ def add(self, boost_values=None, atomic_updates=True, **fields):
lst.append("<doc>")

for f, v in fields.items():

# Add update="set" attribute to each field except for the uniqueKey
# field.
if f == uniqueKey:
Expand Down Expand Up @@ -316,7 +315,16 @@ def add(self, boost_values=None, atomic_updates=True, **fields):
tmpl = '<field name="%s" update="set" null="true"/>'
lst.append(tmpl % (self.escapeKey(f)))
else:
lst.append(tmpl % self.escapeVal(v))
if v is None:
if f in boost_values:
tmpl = '<field name="%s" boost="%s" update="set" null="true"/>'
tmpl = tmpl % (self.escapeKey(f), boost_values[f])
else:
tmpl = '<field name="%s" update="set" null="true"/>'
tmpl = tmpl % (self.escapeKey(f))
lst.append(tmpl)
else:
lst.append(tmpl % self.escapeVal(v))
lst.append("</doc>")
lst.append("</add>")
xstr = "".join(lst)
Expand Down

0 comments on commit 43858be

Please sign in to comment.