1. solr的schema.xml主键的注意事项
solr中主键必须是string类型的。
2. copyFiled和defaultSearchField配合使用,schema.xml如下配置:
<fields> <field name="id" type="string" indexed="true" stored="false" multiValued="true"/> <field name="name" type="text" indexed="true" stored="false" multiValued="true"/> <field name="address" type="text" indexed="true" stored="false" multiValued="true"/> <field name="all" type="text" indexed="true" stored="false" multiValued="true"/> </fields> <copyField source="name" dest="all"/> <copyField source="address" dest="all"/> <defaultSearchField>all</defaultSearchField>
采用上面的配置,all 非实际字段,他是name和address字段的拷贝,再将all设置为默认搜索字段,这样默认搜索时,会在name和address里面都搜索。
3. 索引全部导入、增量导入、索引删除的命令
全部导入:
http://localhost:8080/genelist/dataimport?command=full-import&commit=true&charset=utf-8
增量导入:
http://localhost:8080/genelist/dataimport?command=delta-import&commit=true&charset=utf-8
按照id删除索引:
http://localhost:8080/genelist/update/?stream.contentType=text/xml;charset=utf-8&commit=true&stream.body=<delete><id>123</id></delete>
按照查询删除索引:(比如删除全部索引)
http://localhost:8080/genelist/update/?stream.contentType=text/xml;charset=utf-8&commit=true&stream.body=<delete><query>*:*</query></delete>
以上命令还有很多选项和参数,使用时可以自己去查找。