Resalat Haque
Resalat Haque

Reputation: 31

How can I get Apache Solr to match documents that only contain some of the search terms?

I am trying to implement Solr search in my php project. I have one text field

<field name="title" type="text_general" indexed="true" stored="true"/>

Example data

Foo Bar

When I try to search by Foo or Foo Bar it works well. But if I try to search by Hello Foo or Hello Bar it is not working.

How can I implement this type search using Solr?

Upvotes: 0

Views: 54

Answers (1)

MatsLindh
MatsLindh

Reputation: 52832

The behavior depends on what the default operator in the schema is set to. If it's set to AND, both terms will have to match. Look for something similar to <solrQueryParser defaultOperator="AND" /> to find out what you've currently set it to.

You can override the setting from schema.xml either by using q.op=OR in the query string, or by using the mm parameter (minimum must match (100% => AND, 0% => OR), which allows you to say "at least 75% of the terms must be present in the field).

Upvotes: 2

Related Questions