solr query with white space

后端 未结 5 1840
轻奢々
轻奢々 2020-12-05 22:54

I search for a word and I get the results with facet as follows:


108
&l         


        
相关标签:
5条回答
  • 2020-12-05 23:27

    I guess you can use

    fq={!raw f=itemtype}Supply Chain Intermediaries
    

    for that purpose

    It tuns out that you have to use !term instead of !raw for Solr version >= 4.0

    http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201012.mbox/%3C4D121F73.3090706@jhu.edu%3E

    Have a nice day.

    0 讨论(0)
  • 2020-12-05 23:40

    How is your itemtype field analysed?

    If it is of type string , then use:

    fq=itemtype:"Supply Chain Intermediaries"
    

    Otherwise you can also try:

    fq=itemtype:(Supply Chain Intermediaries)
    

    Assuming OR is the default operator in your config and text is the default search field, your query will get translated to:

    fq=itemtype:Supply OR text:(Chain Intermediaries)
    

    Chain and Intermediaries are searched against default search field.

    0 讨论(0)
  • 2020-12-05 23:44

    This doesn't answer this question directly but it may help with this problem:

    Remove the spaces before posting to Solr.

    For fields used for faceting rather than searching, it is not important to store the value with spaces. The value is simply a treated as key. Store the field itemtype like so:"supplychainintermediaries", "monitorauditorfirm", etc.

    When you display the facet values to the user, simply use a dictionary which maps key values to display values. Like so:

    "supplychainintermediaries" --> "Supply Chain Intermediaries" "monitorauditorfirm" --> "Monitor/Auditor Firm"

    0 讨论(0)
  • 2020-12-05 23:45

    I have fixed white space issue by replacing :

    $tmp[] = $name . ':' . $this->_escapeValue($value);
    

    with :

    $tmp[] = $name . ':' .'"'. $this->_escapeValue($value).'"';
    

    Means by adding quotation after escape value in SolrSource.php file.

    0 讨论(0)
  • 2020-12-05 23:49

    I have tried different solutions mentioned here, but none of them worked. However I solved it like this:

    fq=itemtype: *Supply\ Chain\ Intermediaries*
    

    Here space will be escaped with \

    The above string will match with the strings Lorem Supply Chain Intermediaries Ipsum

    If you are having a word starts with Supply Chain Intermediaries Ipsum then just give

    fq=itemtype: Supply\ Chain\ Intermediaries*
    
    0 讨论(0)
提交回复
热议问题