You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Barbet Alain <al...@gmail.com> on 2017/08/29 09:43:28 UTC

What do field(..) on fl parameter ?

Hi !

I was previously using field(..) to escape some parameter on field name.
Like this:

fl=field(my:data)

Not good to use it on binary data as you will get "Can't initialize
DocTermsIndex to generate (function) FunctionValues for field:
my:data"

So now I use

fl=my*data

And it work's like a charm.

But I have another field:

  <field name="created" type="long"  docValues="false"
multiValued="false" stored="true" />

Example of data:

20170716122807

If I create a base from scratch, it's work:

./bin/solr create -c test_long
curl http://localhost:8983/solr/test_long/schema -X POST -H
'Content-type:application/json' --data-binary '{
    "add-field" : {
        "name":"name",
        "type":"text_general",
        "multiValued":false,
        "stored":true
    },
    "add-field" : {
        "name":"mydate",
        "type":"long",
        "multiValued":false,
        "docValues":false,
        "stored":true
    }
}'

./bin/post -c test_long -type "application/json" -d '
[
  {
    "name": "test name",
    "mydate" : "20170716122807"
  }
]
'
curl "http://localhost:8983/solr/test_long/select?q=*:*&fl=name,mydate"
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int
name="QTime">2</int><lst name="params"><str name="q">*:*</str><str
name="fl">name,mydate</str></lst></lst><result name="response"
numFound="1" start="0"><doc><str name="name">test name</str><long
name="mydate">20170716122807</long></doc></result>
</response>

But if I use my old base (migrated from lucene 2.9 => 3 => 4 =>5),
it's fail with:

select?q=*:*&fl=created
java.lang.NullPointerException
        at org.apache.lucene.util.LegacyNumericUtils.prefixCodedToLong(LegacyNumericUtils.java:189)

But if use field(...) it's work ...
select?q=*:*&fl=field(created)"
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int
name="QTime">0</int><lst name="params"><str name="q">*:*</str><str
name="fl">field(created)</str></lst></lst><result name="response"
numFound="364735" start="0"><doc><long
name="field(created)">20170716122747</long></doc>
....


Can someone explain me this behavior ? How avoid the
java.lang.NullPointerException ? What's do field(..) ?

Thank you for your help