Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

While indexing, Solr returns 400 Status Bad Request when integer fieldtype is left empty

In my Solr schema.xml, I have an integer field and text_general field

<field name="popularity" type="int" indexed="true" stored="true" />
<field name="priority" type="text_general" indexed="true" stored="true" />

When I try to index following data onto Solr, I get "400" Status: Bad Request

    <add>
        <doc>
            <field name="popularity"></field>
            <field name="id">id_001</field>
            <field name="priority">10</field>
        </doc>
    </add>

While it works well when I index following data:

    <add>
        <doc>
            <field name="popularity">5</field>
            <field name="id">id_002</field>
            <field name="priority"></field>
        </doc>
    </add>

So does that mean integer field can not be empty, while text_general can be?

I am using SolrPHPClient to index data. http://code.google.com/p/solr-php-client/

like image 432
Aujasvi Chitkara Avatar asked Feb 17 '26 10:02

Aujasvi Chitkara


1 Answers

Isn't it also valid to not use a field that you don't want to set, so something like:

<add>
    <doc>
        <field name="id">id_001</field>
        <field name="priority">10</field>
    </doc>
</add>
like image 113
dlamblin Avatar answered Feb 18 '26 23:02

dlamblin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!