0

Is there a way to get records which matches a query partially in Solr.

For &q="java enterprise" in the below mentioned records,

{
 "name":"java",
  "case:"enterprise",
},

{
 "name":"java enterprise"
 "case": "enterprise"
}

I want to fetch only those records which have java and enterprise mentioned separately and not together, i.e only the below record should come into my result.

 {
     "name":"java",
      "case:"enterprise",
 }

Is there a way to search for only those records and eliminate the documents from the search which has exact match?

Kabhi
  • 135
  • 1
  • 12
  • What happens if there are more than two terms being searched? – MatsLindh Jun 08 '18 at 07:31
  • @MatsLindh In case of three or more terms, it should perform the same way. No records with exact match should appear. The partial matching records can be ordered score wise which is default in solr. – Kabhi Jun 08 '18 at 08:44
  • 1
    If you can control what values goes in (i.e. they're not directly from user search), you can [use `sum()` and `termfreq()` together with frange](https://stackoverflow.com/a/16548210/137650) to build something like that - does that approach work? – MatsLindh Jun 08 '18 at 08:51
  • @MatsLindh Yes. I think this would work. Thanks. However, I had a more organized question to accomplish something like this in Solr [here](https://stackoverflow.com/questions/50564654/solr-differentiating-between-exact-match-and-partial-match-or-grouping-based-o). Do you think it can be done? – Kabhi Jun 10 '18 at 07:23

1 Answers1

0

You don't need to use exact phrase match, instead, you can use boolean queries in that case

(name:"java" AND case:"enterprise" ) OR (name:"enterprise" AND case:"java" )
Oyeme
  • 11,088
  • 4
  • 42
  • 65
  • 1
    This will grow rather quickly as the number of terms increase, though. For just two terms it'll work fine, but otherwise I think parsing the output from debugQuery or sum + termfreq is better. – MatsLindh Jun 08 '18 at 18:29