gpt4 book ai didi

tomcat - 用 q=* :* && q={keyword} && q=field:{keyword} in solr 4. 9 查询

转载 作者:行者123 更新时间:2023-11-28 22:41:37 29 4
gpt4 key购买 nike

  • 我刚刚找到有关 apache solr 的信息,并且在我成功安装了带有 Tomcat 的 apache Solr 之后。然后我开始使用 Apache Solr 进行搜索。
  • 但我对 Apache Solr 的结果有一些疑问。
  • 当我查询与以下字段相同的字段时:title: love,并且 URL 与:
    • http://my_ip:8080/solr/music/select?q=title%3A+love&wt=json&indent=true
    • Apache Solr 返回了 很多结果title 与单词 love 匹配。
  • 这里的问题如果我查询与:love 相同,并且 URL 与:
    • http://my_ip:8080/solr/music/select?q=love&wt=json&indent=true
    • Apache Solr 没有返回任何结果

我想问一下为什么q=love没有返回任何结果?希望大家帮帮我。非常感谢。

这是我的schema.xml 文件:

<schema name="example" version="1.5">
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="_root_" type="string" indexed="true" stored="false"/>
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text_vi" indexed="true" stored="true"/>
<field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>
<field name="type_music" type="text_vi" indexed="true" stored="true"/>

<dynamicField name="*_i" type="int" indexed="true" stored="true"/>
<dynamicField name="*_is" type="int" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_s" type="string" indexed="true" stored="true" />
<dynamicField name="*_ss" type="string" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_l" type="long" indexed="true" stored="true"/>
<dynamicField name="*_ls" type="long" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_t" type="text_general" indexed="true" stored="true"/>
<dynamicField name="*_txt" type="text_general" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_en" type="text_en" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
<dynamicField name="*_bs" type="boolean" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_f" type="float" indexed="true" stored="true"/>
<dynamicField name="*_fs" type="float" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_d" type="double" indexed="true" stored="true"/>
<dynamicField name="*_ds" type="double" indexed="true" stored="true" multiValued="true"/>

<!-- Type used to index the lat and lon components for the "location" FieldType -->
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false" />

<dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
<dynamicField name="*_dts" type="date" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_p" type="location" indexed="true" stored="true"/>

<!-- some trie-coded dynamic fields for faster range queries -->
<dynamicField name="*_ti" type="tint" indexed="true" stored="true"/>
<dynamicField name="*_tl" type="tlong" indexed="true" stored="true"/>
<dynamicField name="*_tf" type="tfloat" indexed="true" stored="true"/>
<dynamicField name="*_td" type="tdouble" indexed="true" stored="true"/>
<dynamicField name="*_tdt" type="tdate" indexed="true" stored="true"/>

<dynamicField name="*_c" type="currency" indexed="true" stored="true"/>

<dynamicField name="ignored_*" type="ignored" multiValued="true"/>
<dynamicField name="attr_*" type="text_general" indexed="true" stored="true" multiValued="true"/>

<dynamicField name="random_*" type="random" />
<uniqueKey>id</uniqueKey>

<fieldType name="string" class="solr.StrField" sortMissingLast="true" />

<!-- boolean type: "true" or "false" -->
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>
<fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0"/>
<fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0"/>
<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>
<fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>

这是我的solrconfig.xml 文件:

<luceneMatchVersion>4.9</luceneMatchVersion>
<lib dir="../../../contrib/analysis-extras/lib" regex=".*\.jar" />
<lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />
<lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />
<lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />
<lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />
<lib dir="../../../contrib/dataimporthandler/lib" regex=".*\.jar" />
<lib dir="/home/my_name/apache_solr/apache-tomcat-8.0.24/dist" regex="solr-dataimporthandler-4.9.0.jar" />
<lib dir="/home/my_name/apache_solr/apache-tomcat-8.0.24/dist" regex="solr-dataimporthandler-extras-4.9.0.jar" />
<lib dir="../../../lib" regex="mysql-connector-java-5.1.31-bin.jar" />

这是 data-config.xml 文件:

<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1/sieunhac_development" user="root" password=""/>
<document name="musics">
<entity name="musics" pk="id"
query="select p.id, LCASE(p.title) as title, birthday_singer, p.type_music from musics p order by updated_at desc;">
<field column="id" name="id" template="id"/>
<field column="title" name="title"/>

<field name="type_music" column="type_music" />
</entity>
</document>
</dataConfig>

最佳答案

如果您查看 solrconfig.xml 文件,您会看到 /select requestHandler 配置了默认搜索字段:

<lst name="defaults">
<str name="df">name</str>
</lst>

在这里,您可以输入您想要的字段,例如:

<lst name="defaults">
<str name="df">title</str>
</lst>

你可以看到另一个关于this subject的主题和 Solr Documentation .

更新

要回答您的评论,您可以在 schema.xml 中创建一个新字段:

<field name="searchable_field" type="text_general" indexed="true" stored="true"  multiValued="true" />

之后,您可以在新字段中复制所需的字段:

<copyField source="title" dest="searchable_field"/>
<copyField source="author" dest="searchable_field"/>
<copyField source="production" dest="searchable_field"/>

最后,您只需将这个新字段放入您的 solrconfig.xml 中:

<lst name="defaults">
<str name="df">searchable_field</str>
</lst>

关于tomcat - 用 q=* :* && q={keyword} && q=field:{keyword} in solr 4. 9 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31567884/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com