0

I have a solr schema consisting of name and idnumber.

  • name column stores name of a person
  • idnumber stores numbers of passport/driving license ets.

My search condition is like

Get all results when the name of person is 'ABC' or idnumber is '123'

I used the query

(name:'MAHMUD ABID HAMID BID HAMID' OR idnumber:123) 
AND  (name:'MAHMUD' AND name:'ABID AND name:'HAMID' AND name:'BID' AND 
      name:'HAMID' OR idnumber:123)

But I am not getting the result as per my requirement.

cheffe
  • 9,345
  • 2
  • 46
  • 57
  • What's wrong with just `name:'MAHMUD ABID HAMID BID HAMID' OR idnumber:123`? – Amadan Mar 27 '15 at 05:49
  • @Amadan when i apply minimum match to name and idnumber i am not getting any results, if the minimum match is for name alone then some results are coming, but not accurate – ans_Learning..... Mar 27 '15 at 06:16
  • Then you misreported your stated requirement. You said "Get all results when the name of person is 'ABC' or idnumber is '123' ". (Also, use backticks - \` - for code quoting, not tags.) – Amadan Mar 27 '15 at 06:18
  • @Amadan just as we have `UNION` in SQL, is there any method in solr – ans_Learning..... Mar 27 '15 at 06:21
  • No - http://stackoverflow.com/questions/4388005/solr-execute-multiple-queries-in-one-request . But you can do an almost-union using OR queries. But again, what exactly is it you're trying to do? Find full name, number or partial name, with partial name being less important? Because you just said that what you wrote in your OP was not correct. – Amadan Mar 27 '15 at 06:26
  • @Amadan what i need is get all names exactly as `MAHMUD ABID HAMID BID HAMID` or all names having `idnumber:123`. if I search as `name:'MAHMUD ABID HAMID BID HAMID' OR idnumber:123` then i get all names having atleast one match – ans_Learning..... Mar 27 '15 at 06:30
  • Oh, ok, finally understood - `name:'MAHMUD ABIT'` is not looking for `MAHMUD ABIT`, but also finding `MAHMUD` only? It might be wrong quotes: 'A phrase is a group of words surrounded by *double quotes* such as `"hello dolly"`'. Try `name:"MAHMUD ABID HAMID BID HAMID" OR idnumber:123`? – Amadan Mar 27 '15 at 06:49
  • @Amadan: Still there is an issue, if the postion of **firstname** and **lastname** changes as `ABIT MAHMUD` instead of `MAHMUD ABIT` then there is no output. – ans_Learning..... Mar 27 '15 at 08:26
  • There shouldn't be any output, as you said: "what i need is get all names exactly as `MAHMUD ABID HAMID BID HAMID` or all names having `idnumber:123`". "exactly" is not the same as "having all of the same words in any order". I give up, you can't explain what you want. – Amadan Mar 27 '15 at 08:57
  • A schema snippet for the field you try to query would increase your chances of getting this answered. – ilinca Mar 27 '15 at 10:39

0 Answers0