From schema.xml:
<field name="myfield" type="integer" indexed="true" stored="false"/>
The record with id 5 has myfield
with value of 0, which I've confirmed开发者_开发百科 by searching for plain id:5
and looking at the objectXml.
A search for id:5 AND myfield:0
returns no records.
A search for id:5 AND -myfield:1
, however, returns the record I am expecting.
Why?
-- Additional info:
Definition for integer type:
<fieldType name="integer" class="solr.IntField" omitNorms="true"/>
Solr version: 1.4
What is the class that is bound to the "integer" field type? Does it treat 0 as a marker for not indexing?
What does the index data on that document look like in the admin?
I tried your case assuming you used the standard fieldtype for int:
<fieldtype name="integer" class="solr.TrieIntField" ... />
That works fine. So i guess the field type definition of integer
is somehow wrong. Check this definition.
I've solved the issue. It was a bug in the core of the application (third party CMS) and had nothing to do with Solr.
The problem was that the vendor's code was verifying to see if the value being indexed was not false before indexing it. Unfortunately, they were doing so like this:
$value = strval($node);
if ($value)
Of course, 0 evaluates to false, even if it's the string "0".
I changed it to:
$value = strval($node);
if ($value !== false)
... and now it works.
Thank you for your efforts and sorry the problem ended up being something completely unrelated.
Numeric fields require numeric queries. Try giving a type of something other than numeric for your field.
精彩评论