Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql lucene搜索查询在solr4.6中不起作用_Mysql_Solr - Fatal编程技术网

Mysql lucene搜索查询在solr4.6中不起作用

Mysql lucene搜索查询在solr4.6中不起作用,mysql,solr,Mysql,Solr,我们有数百万张唱片。最初我们使用lucene对数据进行索引,但由于OutOfMemory异常,我们决定将数据移动到solr。下面是我们在schema.xml中声明的字段,用于执行索引和搜索操作 <field name="product" type="string" indexed="true" stored="true" multiValued="false" /> <field name="source" type="string" in

我们有数百万张唱片。最初我们使用lucene对数据进行索引,但由于OutOfMemory异常,我们决定将数据移动到solr。下面是我们在schema.xml中声明的字段,用于执行索引和搜索操作

 <field name="product"      type="string"   indexed="true"  stored="true"  multiValued="false" />
 <field name="source"       type="string"   indexed="true"  stored="true"  multiValued="false" />
 <field name="target"       type="string"   indexed="true"  stored="true"  multiValued="false" />
 <field name="pos"          type="string"   indexed="true"  stored="true"  multiValued="false" />
 <field name="company"     type="string"   indexed="true"  stored="true"  multiValued="false" />
 <field name="deprecated"   type="string"   indexed="true"  stored="true"  multiValued="false" />
 <field name="id"           type="string"   indexed="true"  stored="true"  multiValued="false" required="true"/>
在lucene中,当用户在UI中键入短语时,以下查询在精确搜索、模糊搜索等中工作

例:推出新品牌

在lucene中进行精确搜索
searchstr=(来源:“abc”或目标:“abc”或不推荐的:“abc”)和公司:“tc”

模糊搜索:
searchstr=(来源:新品牌发布~0.7或目标:新品牌发布~0.7或弃用:新品牌发布~0.7)和公司:“bb”

默认搜索

searchstr=(来源:新品牌推出*或目标:新品牌推出*或不推荐:新品牌推出*)和公司:“cc”

现在在solr中,上述查询不起作用。当用户在UI中输入上述“新品牌发布”短语时,结果为零。有时我们会遇到lucene中没有的区分大小写的问题

请告诉我哪里做错了

  • 您已声明字符串类型的所有字段。字符串字段类型不标记化。你真的想要这种行为吗

  • (来源:新品牌推出*或目标:新品牌推出*或弃用:新品牌推出*)和公司:“cc”

    如果在要搜索的文本周围不使用双引号,那么在SOLR中它将不是短语查询。所以
    来源:新推出的品牌*
    实际上会被搜索为
    来源:New或defaultField:Brand或defaultField:launched*

    其中defaultField将是schema.xml中定义的默认字段,和/或将按照schema.xml中指定的默认运算符使用。而是搜索
    来源:“新品牌发布”


  • 查看SOLR文档了解更多信息。

    在我的应用程序中,我想使用类似搜索的短语。我想搜索“New Brand laun*”,应该只得到“New Brand launched”的结果,但正如你们提到的,这是在源字段中搜索“New”,其余的单词在默认字段中搜索。我想得到我从SQL查询中得到的行为,例如:field1类似于“new brand laun*”或field2类似于“new brand laun*”。我如何才能实现这种行为。
    SolrQuery solrQuery=new SolrQuery();
    solrQuery.setQuery("id:*_TB");
    solrQuery.setRows(10000);
    solrQuery.addFilterQuery(searchStr);//
    QueryResponse rsp = httpserver.query(solrQuery);