11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Working with External Files and Processes<br />

The ExternalFileField Type<br />

Format of the External File<br />

Reloading an External File<br />

The PreAnalyzedField Type<br />

JsonPreAnalyzedParser<br />

SimplePreAnalyzedParser<br />

The ExternalFileField Type<br />

The ExternalFileField type makes it possible to specify the values for a field in a file outside the <strong>Solr</strong> index.<br />

For such a field, the file contains mappings from a key field to the field value. Another way to think of this is that,<br />

instead of specifying the field in documents as they are indexed, <strong>Solr</strong> finds values for this field in the external file.<br />

External fields are not searchable. They can be used only for function queries or display. For more<br />

information on function queries, see the section on Function Queries.<br />

The ExternalFileField type is handy for cases where you want to update a particular field in many<br />

documents more often than you want to update the rest of the documents. For example, suppose you have<br />

implemented a document rank based on the number of views. You might want to update the rank of all the<br />

documents daily or hourly, while the rest of the contents of the documents might be updated much less<br />

frequently. Without ExternalFileField, you would need to update each document just to change the rank.<br />

Using ExternalFileField is much more efficient because all document values for a particular field are stored<br />

in an external file that can be updated as frequently as you wish.<br />

In<br />

schema.xml, the definition of this field type might look like this:<br />

<br />

The keyField attribute defines the key that will be defined in the external file. It is usually the unique key for the<br />

index, but it doesn't need to be as long as the keyField can be used to identify documents in the index. A defV<br />

al defines a default value that will be used if there is no entry in the external file for a particular document.<br />

The valType attribute specifies the actual type of values that will be found in the file. The type specified must be<br />

either a float field type, so valid values for this attribute are pfloat, float or tfloat. This attribute can be<br />

omitted.<br />

Format of the External File<br />

The file itself is located in <strong>Solr</strong>'s index directory, which by default is $SOLR_HOME/data. The name of the file<br />

should be external_ fieldname or external_ fieldname.*<br />

. For the example above, then, the file could<br />

be named external_entryRankFile or external_entryRankFile.txt.<br />

If any files using the name pattern (such as ) appear, the last (after being sorted by name) will<br />

.* .txt<br />

be used and previous versions will be deleted. This behavior supports implementations on systems<br />

where one may not be able to overwrite a file (for example, on Windows, if the file is in use).<br />

The file contains entries that map a key field, on the left of the equals sign, to a value, on the right. Here are a<br />

few example entries:<br />

doc33=1.414<br />

doc34=3.14159<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

61

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!