ExternalFileField in Solr 3.6

2019-06-07 23:13发布

问题:

I am trying to use Solr 3.6.1 ExternalFileField. Here is my fieldtype definition:

<fieldtype name="file" keyField="id" defVal="0" stored="true" indexed="true" class="solr.ExternalFileField" valType="float"/>

and here is the field definition:

<field name="fviews" type="file"/>

I was able to test it by sorting on fviews like

http://localhost:8983/solr/select?q=tag_id:1&sort={!func}fviews desc

and it is working correctly.

But I am running into two issues:

I need this field back in my search results. Even though I've marked the field as stored="true" I do not get it back. I even tried adding &fl=* query param but it doesn't work.

If I make changes to the external file, they are not getting reflected in the search results immediately (which is the very reason why I wanted to use external file field). The documentation for solr 4.0 at https://lucene.apache.org/solr/api-4_0_0-BETA/org/apache/solr/schema/ExternalFileField.html reads "If the external file has already been loaded, and it is changed, those changes will not be visible until a commit has been done.". I tried doing a commit using http://localhost:8983/solr/update?commit=true in the hope that Solr may read the edited file based on modified timestamp, but it does not work. However, if I do a full import, then the results are correct.

Update (Answer): The 2nd question has been answered by @Persimmonium below. The answer for the first question (how to retrieve the value) is to use fl=*,field(EXTERNAL_FILE_FIELD_NAME) as mentioned in this blog post I wrote.

回答1:

Regarding external field not being returned, I was not aware of that, but it is probably a limitation of such fields, as they cannot be searched either.

Regarding reloading, I had to do this so they were reloaded:

In solrconfig.xml add the following handler:

<requestHandler name="/reloadCache" class="org.apache.solr.search.function.FileFloatSource$ReloadCacheRequestHandler" />

Now modify some values of the file that would change the sorting. And here is the most important thing, hit the following url otherwise Solr will not use the new values.

http://your.host:8983/solr/core0/reloadCache



标签: solr