You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by dtphat <ph...@gmail.com> on 2013/10/25 08:02:11 UTC

Solr search in case the first keyword are not index

I have a problem with solr search: 
I have keyword, example: "apache solr reference", I index for "apache",
"solr", "reference".
when I search with the list keywords below:
- apache solr reference -> OK
- apache -> OK
- solr -> OK
- the same.

But when the first keyword is not index, and other keywords are index, solr
can not query it.
(example I search with: apacheee solr reference).

Anyone can help me to solr this problem.

<below is the configuration for indexing and querying in schema.xml>

<fieldtype name="text_general_2" class="solr.TextField"
positionIncrementGap="1000">
	  <analyzer>
		<tokenizer class="solr.ICUTokenizerFactory"/>
		  <filter class="solr.StandardTokenizerFactory" />
		  <filter class="solr.ICUFoldingFilterFactory"/>
		  <filter class="solr.SynonymFilterFactory" synonyms="stopwords.txt"
ignoreCase="true" expand="false"/>
		  <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt" enablePositionIncrements="true"/>
		  <filter class="solr.CJKWidthFilterFactory"/>
		  <filter class="solr.CJKBigramFilterFactory"/>
	  </analyzer>
</fieldtype>



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-search-in-case-the-first-keyword-are-not-index-tp4097699.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr search in case the first keyword are not index

Posted by dtphat <ph...@gmail.com>.
I have solve it.
Thanks.



-----
Phat T. Dong
--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-search-in-case-the-first-keyword-are-not-index-tp4097699p4098021.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr search in case the first keyword are not index

Posted by dtphat <ph...@gmail.com>.
HI Hoss,
I try to change the default field search to text. But now it still search
only the first word. You can give me more suggest.
Thanks.



-----
Phat T. Dong
--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-search-in-case-the-first-keyword-are-not-index-tp4097699p4098004.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr search in case the first keyword are not index

Posted by dtphat <ph...@gmail.com>.
Thanks for your enthusiasm reply. I will try it.



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-search-in-case-the-first-keyword-are-not-index-tp4097699p4097862.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr search in case the first keyword are not index

Posted by Chris Hostetter <ho...@fucit.org>.
:   "debug": {
:     "rawquerystring": "display_add_level1: apache solr reference",
:     "querystring": "display_add_level1: apache solr reference",
:     "parsedquery": "display_add_level1:apache text:solr text:reference",
:     "parsedquery_toString": "display_add_level1:apache text:solr
: text:reference",

note how your query string is being parsed.

: PROBLEM: when I search with keyword: "test apache " -> no result.
: 
: In others case: multi words I use to search with solr, only the first word
: had indexed will be has result I expect. And others case with the first word
: hadn't indexed, the results will not appear what I expect.

this is because you are specifying... 
   field_name_you_care_about:word1 word2 word3

...so only "word1" is ever being searched for in the field you care about, 
all of the other words are being searched against your default field 
(evidently "text").

If you go back and look at the "explain" information for each of your 
queries (cut from my reply), you'll see that nothing is ever matching 
against the text field, so only the first word of each of your test 
queries ever matters.

you either need to change your query syntax, or change the default field 
you are using, or both.

-Hoss

Re: Solr search in case the first keyword are not index

Posted by dtphat <ph...@gmail.com>.
Hi Chris,
My parser operand now is "OR" not "AND", in schema.xml I define: 
<solrQueryParser defaultOperator="OR"/>

I use below config to index (integrate detecting language in other config).
<analyzer type="index">
		<tokenizer class="solr.ICUTokenizerFactory"/>
		  <filter class="solr.StandardTokenizerFactory" />
		  <filter class="solr.ICUFoldingFilterFactory"/>
		  <filter class="solr.SynonymFilterFactory" synonyms="stopwords.txt"
ignoreCase="true" expand="false"/>
		  <filter class="solr.CJKWidthFilterFactory"/>
		  <filter class="solr.CJKBigramFilterFactory"/>
	  </analyzer>

I will show details example search with keyword : "apache solr reference"
which I index for separated word "apache", "solr", "reference" in below.

When I search with keyword: "apache solr reference" -> Has result.
"response": {
    "numFound": 1,
    "start": 0,
    "docs": [
      {
        "add_level1_id": "1",
        "id": "2",
        "language_code": "en",
        "display_add_level1": "apache solr reference",
        "_version_": 1449914865555603500
      }
    ]
  },
  "debug": {
    "rawquerystring": "display_add_level1: apache solr reference",
    "querystring": "display_add_level1: apache solr reference",
    "parsedquery": "display_add_level1:apache text:solr text:reference",
    "parsedquery_toString": "display_add_level1:apache text:solr
text:reference",
    "explain": {
      "2": "\n0.2823743 = (MATCH) product of:\n  0.84712285 = (MATCH) sum
of:\n    0.84712285 = (MATCH) weight(display_add_level1:apache in 7)
[DefaultSimilarity], result of:\n      0.84712285 = score(doc=7,freq=1.0 =
termFreq=1.0\n), product of:\n        0.50553745 = queryWeight, product
of:\n          3.3513753 = idf(docFreq=1, maxDocs=21)\n          0.15084477
= queryNorm\n        1.6756877 = fieldWeight in 7, product of:\n         
1.0 = tf(freq=1.0), with freq of:\n            1.0 = termFreq=1.0\n         
3.3513753 = idf(docFreq=1, maxDocs=21)\n          0.5 = fieldNorm(doc=7)\n 
0.33333334 = coord(1/3)\n"
    },
    "QParser": "LuceneQParser",
    "timing": {
      "time": 3,
      "prepare": {
        "time": 2,
        "query": {
          "time": 2
        },
        "facet": {
          "time": 0
        },
        "mlt": {
          "time": 0
        },
        "highlight": {
          "time": 0
        },
        "stats": {
          "time": 0
        },
        "debug": {
          "time": 0
        }
      },
      "process": {
        "time": 1,
        "query": {
          "time": 0
        },
        "facet": {
          "time": 0
        },
        "mlt": {
          "time": 0
        },
        "highlight": {
          "time": 0
        },
        "stats": {
          "time": 0
        },
        "debug": {
          "time": 1
        }
      }
When I search with keyword: "apacher" -> Has result.
"response": {
    "numFound": 1,
    "start": 0,
    "docs": [
      {
        "add_level1_id": "1",
        "id": "2",
        "language_code": "en",
        "display_add_level1": "apache solr reference",
        "_version_": 1449914865555603500
      }
    ]
  },
  "debug": {
    "rawquerystring": "display_add_level1: apache",
    "querystring": "display_add_level1: apache",
    "parsedquery": "display_add_level1:apache",
    "parsedquery_toString": "display_add_level1:apache",
    "explain": {
      "2": "\n1.6756877 = (MATCH) weight(display_add_level1:apache in 7)
[DefaultSimilarity], result of:\n  1.6756877 = fieldWeight in 7, product
of:\n    1.0 = tf(freq=1.0), with freq of:\n      1.0 = termFreq=1.0\n   
3.3513753 = idf(docFreq=1, maxDocs=21)\n    0.5 = fieldNorm(doc=7)\n"
    },
    "QParser": "LuceneQParser",
    "timing": {
      "time": 3,
      "prepare": {
        "time": 1,
        "query": {
          "time": 1
        },
        "facet": {
          "time": 0
        },
        "mlt": {
          "time": 0
        },
        "highlight": {
          "time": 0
        },
        "stats": {
          "time": 0
        },
        "debug": {
          "time": 0
        }
      },
      "process": {
        "time": 2,
        "query": {
          "time": 1
        },
        "facet": {
          "time": 0
        },
        "mlt": {
          "time": 0
        },
        "highlight": {
          "time": 0
        },
        "stats": {
          "time": 0
        },
        "debug": {
          "time": 1
        }
      }
When I search with keyword: "solr" -> Has result. (the same for keyword
reference).
"response": {
    "numFound": 1,
    "start": 0,
    "docs": [
      {
        "add_level1_id": "1",
        "id": "2",
        "language_code": "en",
        "display_add_level1": "apache solr reference",
        "_version_": 1449914865555603500
      }
    ]
  },
  "debug": {
    "rawquerystring": "display_add_level1: solr",
    "querystring": "display_add_level1: solr",
    "parsedquery": "display_add_level1:solr",
    "parsedquery_toString": "display_add_level1:solr",
    "explain": {
      "2": "\n1.6756877 = (MATCH) weight(display_add_level1:solr in 7)
[DefaultSimilarity], result of:\n  1.6756877 = fieldWeight in 7, product
of:\n    1.0 = tf(freq=1.0), with freq of:\n      1.0 = termFreq=1.0\n   
3.3513753 = idf(docFreq=1, maxDocs=21)\n    0.5 = fieldNorm(doc=7)\n"
    },
    "QParser": "LuceneQParser",
    "timing": {
      "time": 2,
      "prepare": {
        "time": 1,
        "query": {
          "time": 1
        },
        "facet": {
          "time": 0
        },
        "mlt": {
          "time": 0
        },
        "highlight": {
          "time": 0
        },
        "stats": {
          "time": 0
        },
        "debug": {
          "time": 0
        }
      },
      "process": {
        "time": 1,
        "query": {
          "time": 0
        },
        "facet": {
          "time": 0
        },
        "mlt": {
          "time": 0
        },
        "highlight": {
          "time": 0
        },
        "stats": {
          "time": 0
        },
        "debug": {
          "time": 1
        }
      }
When I search with keyword: "solr anykeywords ...." -> Has result. (the same
for keyword " reference anykeywords" ).

PROBLEM: when I search with keyword: "test apache " -> no result.

In others case: multi words I use to search with solr, only the first word
had indexed will be has result I expect. And others case with the first word
hadn't indexed, the results will not appear what I expect.

You can let me now to clearly this problem.
Thanks
-Phat



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-search-in-case-the-first-keyword-are-not-index-tp4097699p4097857.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr search in case the first keyword are not index

Posted by Chris Hostetter <ho...@fucit.org>.
: But when the first keyword is not index, and other keywords are index, solr
: can not query it.
: (example I search with: apacheee solr reference).

run your queries in a browser and add "debug=query" to see how your query 
is being parsed.

you most likely are seeing the results of the parser defaulting to "AND" 
-- ie: requiring all query terms.

If you want to match as many of the query terms as possible, but only 
require that at least 1 matches, you need to set the default operator 
(q.op) to "OR" ...

https://cwiki.apache.org/confluence/display/solr/The+Standard+Query+Parser

...either that, or consider using an alternative parser like 
dismax/edismax and configuring them to be linient in terms of how many 
clauses must match something (the "mm" param)...

https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser
https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser

-Hoss