刘同彬
刘同彬

Reputation: 336

solr facet with text field, how to stop solr tokenize it into separate tokens, I want to get the whole field result

  1. I have a text field type named buyer, I need facet on the field. And get the whole value, nor separate tokens, how can I do? thanks a lot.
  2. eg, buyer field value are "beauty inc"、"markwins llc"、"products inc", this is facet result:

facet_counts: {
facet_queries: { },
facet_fields: {
buyer: [
"beauty",
4025,
"inc",
3610,
"products",
1749,
"markwins",
1604,
"llc",
913,
"cosmetics"]
}

it seems that solr tokenize it into separate tokens. How can I get the whole value? If I don't change text field to str field. eg:

facet_counts: {
facet_queries: { },
facet_fields: {
buyer: [
"beauty inc",
3610,
"products llc",
1749,
"markwins llc",
1604]
}
}

Upvotes: 1

Views: 2126

Answers (1)

Alessandro Benedetti
Alessandro Benedetti

Reputation: 1114

<field name="buyer" type="text_general" indexed="true" stored="true"/>
<field name="buyer_facet" type="string" indexed="true" stored="false"/>

<copyField source="buyer" dest="buyer_facet"/>

Then you can search on "buyer" and facet on "buyer_facet" . You need to re-index to fill the buyer_facet field.

Upvotes: 3

Related Questions