0

How do you omit rows with empty records in Solr? I've tried a few permutations but nothing seems to be working:

1: "John", "blue", "dog" 2: "Sue", "brown", "zebra" 3: "Mike", "red", "" <--do not return this row with the results 4: "Jen", "green", "cat"

Raydot
  • 1,458
  • 1
  • 23
  • 38
  • These do not look like Solr docs. Are you talking abt multi-valued fields? What do you mean by "rows"? – arun Oct 17 '14 at 21:24
  • Sorry, I come to this more from SQL. No, those are not actual Solr docs, just a pseudo-code example of related record sets. I want 1, 2, and 4 but not 3 because the 3rd value in 3 has nothing in it. – Raydot Oct 17 '14 at 21:28
  • Why did 3 match your query then? I am not sure what your query is and what type the field is indexed as – arun Oct 17 '14 at 21:58
  • 3 shouldn't match my query because it has an empty field. Only 1, 2, and 4 should match my query. This is not an actual example. I don't know what the query is to return only 1, 2, and 4 but not 3, which is my question. – Raydot Oct 17 '14 at 22:09
  • Here is a more specific example: ABC 12345 Open Öffnen Abra Ouvrez Aprire DEF 23456 OpenGL OpenGL OpenGL – Raydot Oct 17 '14 at 22:10
  • The first doc contains a string named "esp," the second one doesn't. So if fq = enu:open (as it does in both docs) how do I omit the second doc which does not have an esp field? – Raydot Oct 17 '14 at 22:20

1 Answers1

1

esp:[* TO *] restricts to documents which contain esp field, so your query could be like:

q=esp:[* TO *]&fq=enu:open
arun
  • 10,685
  • 6
  • 59
  • 81
  • Close...turns out to be q:*:*&fq:[enu:open, esp:[* TO *]] or something more like that. If you edit to reflect this I'm more than glad to award points! – Raydot Oct 20 '14 at 21:21
  • 1
    Well, yes, you can add it as another filter query, but only if you want to cache the results in filter cache. You should understand the difference between `q` and `fq` before using `fq` for all the conditions. See http://stackoverflow.com/a/14866752/1333610 – arun Oct 21 '14 at 00:54
  • Thanks for pointing me to that post. I get the difference between f and fq not but then I don't understand. Wouldn't it be the other way around? q=enu:open&fq=esp:[* TO *] or "Search all records where enu contains open and then filter out the ones that don't contain esp?" – Raydot Oct 21 '14 at 22:16
  • Never mind, just answered my own stupid question. Thanks Arun! – Raydot Oct 21 '14 at 22:40