Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Solr string field or text field?

Tags:

solr

In apache Solr why do we always need to prefer string field over text field if both solves purposes?

How string or text affects the parameters like index size, index read, index creation?

like image 817
Rahul Avatar asked Aug 24 '11 12:08

Rahul


People also ask

What is field type in Solr?

A field type defines the analysis that will occur on a field when documents are indexed or queries are sent to the index. A field type definition can include four types of information: The name of the field type (mandatory). An implementation class name (mandatory).

What is Solr full text search?

Solr is a mighty tool to perform full text search with many of extra features, such as (various kinds of) facets, "Did you mean?" functionality and highlighting with suitable selection of text snippets for an extract.

What is the difference between Q and FQ in Solr?

Standard solr queries use the "q" parameter in a request. Filter queries use the "fq" parameter. The primary difference is that filtered queries do not affect relevance scores; the query functions purely as a filter (docset intersection, essentially).


1 Answers

The fields as default defined in the solr schema are vastly different.

String stores a word/sentence as an exact string without performing tokenization etc. Commonly useful for storing exact matches, e.g, for facetting.

Text typically performs tokenization, and secondary processing (such as lower-casing etc.). Useful for all scenarios when we want to match part of a sentence.

If the following sample, "This is a sample sentence", is indexed to both fields we must search for exactly the text This is a sample sentence to get a hit from the string field, while it may suffice to search for sample (or even samples with stemmning enabled) to get a hit from the text field.

like image 62
Johan Sjöberg Avatar answered Oct 13 '22 22:10

Johan Sjöberg