Ako3004
Ako3004

Reputation: 13

Solr/Lucene simple operator "or" missunderstanding / Seach same word in differnt fields

Learning Solr/Lucene Syntax, using Solr Admin in Browser. There I try to search for the same word in two differnt fields with following syntax:

content:myword -> results found

content:myword OR title:existingTitle -> results found

but

content:myword OR title:myword -> ZERO results found, why? It is "or".

also tried without operator which should be equal to "or" , also tried "|" and "||"

this happens when I try to find the same word in one of multipe fields

[edit]

Here are the solr url requests:

content:fahrzeug title:fahrzeug http://xxx/solr/core_de/select?q=content%3Afahrzeug%20title%3Afahrzeug

content:fahrzeug OR title:fahrzeug http://xxx/solr/core_de/select?q=content%3Afahrzeug%20OR%20title%3Afahrzeug

content:fahrzeug | title:fahrzeug http://xxx/solr/core_de/select?q=content%3Afahrzeug%20%7C%20title%3Afahrzeug

{
  "responseHeader":{
    "status":400,
    "QTime":5,
    "params":{
      "q":"content:fahrzeug OR title:fahrzeug",
      "debugQuery":"1"}},
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"invalid boolean value: 1",
    "code":400}}

Upvotes: 1

Views: 810

Answers (1)

Cipous
Cipous

Reputation: 992

I guess, that it is configured like this:

Try: http://www119.pxia.de:8983/solr/core_de/select?fq=content%3Afahrzeug%20title%3Afahrzeug&q=*%3A* - this returns correct documents. So those documents are there if only filtering is used. Query use more complex conditions, your default configuration is:

<requestHandler name="/select" class="solr.SearchHandler">
    <lst name="defaults">
        <str name="defType">edismax</str>
        <str name="echoParams">explicit</str>
        <str name="qf">content^40.0 title^5.0 keywords^2.0 tagsH1^5.0 tagsH2H3^3.0 tagsH4H5H6^2.0 tagsInline^1.0</str>
        <str name="pf">content^2.0</str>
        <str name="df">content</str>
        <int name="ps">15</int>

        <str name="mm">2&lt;-35%</str>
        <str name="mm.autoRelax">true</str>
...

Parser and boosting may play a key role here. I am not familiar with edixmax parser, please check: documentation I would guess mm parameter may be causing this. Anyway its strange, that OR does not work as we are use to from boolean algebra.

"debug":{
"queryBoosting":{
  "q":"title:Home OR content:Perfekt",
  "match":null},
"rawquerystring":"title:Home OR content:Perfekt",
"querystring":"title:Home OR content:Perfekt",
"parsedquery":"+(title:hom content:perfekt)~2 ()",
"parsedquery_toString":"+((title:hom content:perfekt)~2) ()",
"explain":{
  "bf72a75534ba703e4b8dc7194f92ce34223fc0d2/pages/1/0/0/0":"\n4.8893824 = sum of:\n  4.8893824 = sum of:\n    1.9924302 = weight(title:hom in 0) [SchemaSimilarity], result of:\n      1.9924302 = score(doc=0,freq=1.0 = termFreq=1.0\n), product of:\n        1.9924302 = idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:\n          1.0 = docFreq\n          10.0 = docCount\n        1.0 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1) from:\n          1.0 = termFreq=1.0\n          1.2 = parameter k1\n          0.0 = parameter b (norms omitted for field)\n    2.8969522 = weight(content:perfekt in 0) [SchemaSimilarity], result of:\n      2.8969522 = score(doc=0,freq=5.0 = termFreq=5.0\n), product of:\n        1.4816046 = idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:\n          2.0 = docFreq\n          10.0 = docCount\n        1.9552802 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:\n          5.0 = termFreq=5.0\n          1.2 = parameter k1\n          0.75 = parameter b\n          508.3 = avgFieldLength\n          184.0 = fieldLength\n"},
"QParser":"ExtendedDismaxQParser",

Check "parsedquery":"+(title:hom content:perfekt)~2 ()" it basically says, that both title and content must be there: Solr operators

Upvotes: 1

Related Questions