我正在使用 sunspot/solr 为我的 Rails 应用程序构建全文搜索。前几次我能够运行bundle exec rake sunspot:reindex,但后来收到此错误:
RSolr::Error::Http: RSolr::Error::Http - 400 Bad Request
Error: {'responseHeader'=>{'status'=>400,'QTime'=>1},'error'=>{'msg'=>'Exception writing document id Product 1 to the index; possible analysis error.','code'=>400}}
URI: http://localhost:8982/solr/development/update?wt=ruby
Request Headers: {"Content-Type"=>"text/xml"}
Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><add><doc><field name=\"id\">Product 1</field><field name=\"type\">Product</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">Product</field><field boost=\"5\" name=\"code_textp\">Macbook pro 123</field><field name=\"code_textp\"><p>hahahahahhhahahahahhhahahahahhhahahahahhhahahahahhhahahahahhhahahahahhhahahahahh</p></field></doc><doc><field name=\"id\">Product 2</field><field name=\"type\">Product</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">Product</field><field boost=\"5\" name=\"code_textp\">test product</field><field name=\"code_textp\"><p>dfdsfsdfdsfsfsdfsdfdsf</p></field></doc><doc><field name=\"id\">Product 3</field><field name=\"type\">Product</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">Product</field><field boost=\"5\" name=\"code_textp\">Macbook used</field><field name=\"code_textp\"><p>it is refurebishedit is refurebishedit is refurebishedit is refurebishedit is refurebishedit is refurebishedit is refurebished</p></field></doc></add>"
Backtrace: …Run Code Online (Sandbox Code Playgroud) 我想像默认一样使用自定义分析器。在 Hibernate 搜索的文档上在线搜索,我发现可以在 Hibernate 配置中更改它。特别是“hibernate.search.analyzer”属性。然后我做了这个属性
<property name="hibernate.search.analyzer">Class of Analyzer </property>
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何创建分析器的类以在属性中传递它?特别是我想使用“EdgeNGram”,我试图通过 EngedNgram 的 tokenizer 工厂,但它不起作用。
<property name="hibernate.search.analyzer">EdgeNGramTokenizerFactory.class</property>
Run Code Online (Sandbox Code Playgroud)
您能否向我展示我可以在该属性中通过的课程的示例?谢谢
我安装了 SQL Server 全文搜索,创建了目录和索引。我确信数据库中有正确的记录,但 FTS 函数不返回任何结果。
例如:
select * from tablename where contains(title, 'baycan');
select * from tablename where contains(title, '"*baycan*"')
Run Code Online (Sandbox Code Playgroud)
这是目录和索引图像:
searchableAttributes, filterableAttributes, faceting. 我读过这些文件,但有点困惑。
请提供一些有关以下方面的见解: