Solr / Lucene基于多个字段的拼写检查建议(Solr/Lucene spellcheck suggestions based on multiple fields)
我有一个供应商信息的数据库:名称和地址(地址,城市,邮编和国家/地区)。 我需要搜索这个数据库并返回一些供应商。 在搜索框中,用户可以输入任何内容:供应商的名称,地址的一部分,城市,邮编,......如果我找不到任何结果,我需要实施谷歌,如“你的意思是“功能给用户一个建议。
我想过使用Solr / Lucene来做到这一点。 我已经安装了Solr,使用CSV文件导出了我需要的信息,并基于此文件创建了索引。 现在我可以使用solr.SpellCheckComponent从Solr字段获取建议。 事情是我的建议是基于单一领域,需要它从地址,城市,邮编,国家和名称字段获取信息。
在solr配置文件我有这样的事情:
<searchComponent name="spellcheck" class="solr.SpellCheckComponent"> <str name="queryAnalyzerFieldType">textSpell</str> <lst name="spellchecker"> <str name="name">default</str> <str name="field">name</str> <str name="spellcheckIndexDir">spellchecker</str> </lst> </searchComponent> <requestHandler name="/spell" class="solr.SearchHandler" startup="lazy"> <lst name="defaults"> <str name="spellcheck.onlyMorePopular">false</str> <str name="spellcheck.extendedResults">false</str> <str name="spellcheck.count>1</str> </lst> <arr name="last-components"> <str>spellcheck</str> </arr> </requestHandler>
我可以运行如下查询:
http://localhost:8983/solr/spell?q=some_company_name&spellcheck=true&spellcheck.collate=true&spellcheck.build=true
有谁知道如何改变我的配置文件,以获得来自多个领域的建议?
谢谢!!!
I have a database with Vendor's information: name and address (address, city, zip and country fields). I need to search this database and return some vendors. On the search box, the user could type anything: name of the vendor, part of the address, city, zip,... And, if I can't find any results, I need to implement a google like "Did you mean" feature to give a suggestion to the user.
I thought about using Solr/Lucene to do it. I've installed Solr, exported the information I need using CSV file and created the indexes based on this file. Now I am able to get suggestions from a Solr field using solr.SpellCheckComponent. The thing is my suggestion is based in a single field and need it to get information from address, city, zip, country and name fields.
On solr config file I have something like this:
<searchComponent name="spellcheck" class="solr.SpellCheckComponent"> <str name="queryAnalyzerFieldType">textSpell</str> <lst name="spellchecker"> <str name="name">default</str> <str name="field">name</str> <str name="spellcheckIndexDir">spellchecker</str> </lst> </searchComponent> <requestHandler name="/spell" class="solr.SearchHandler" startup="lazy"> <lst name="defaults"> <str name="spellcheck.onlyMorePopular">false</str> <str name="spellcheck.extendedResults">false</str> <str name="spellcheck.count>1</str> </lst> <arr name="last-components"> <str>spellcheck</str> </arr> </requestHandler>
I can run queries like:
http://localhost:8983/solr/spell?q=some_company_name&spellcheck=true&spellcheck.collate=true&spellcheck.build=true
Does anyone know how to change my config file in order to have suggestions from multiple fields?
Thanks!!!
原文:https://stackoverflow.com/questions/7287889
最满意答案
使用过滤器操纵帖子标题。
function change_post_title( $title, $id = null ) { if ( is_single() ) { $title = 'new title'; } return $title; } add_filter( 'the_title', 'change_post_title', 10, 2 );
Thanks all for your help.
I have used a filter but this one :
function modify_post_title($data){ if($data['post_type'] == 'fcfm_photos' && isset($_POST['image'])) { $data['post_title'] = substr($_POST['image'], -(strpos(strrev($_POST['image']),'/'))); } return $data; } add_filter( 'wp_insert_post_data' , 'modify_post_title' , '99', 1 );
And when I save the post, the post title change automatically. This is what i want.
相关问答
更多-
只要一个绊脚石的人都快速注意: get_page_by_title()现在可以处理任何帖子类型。 $post_type参数已添加到WP 3.0中。 Just a quick note for anyone who stumbles across this: get_page_by_title() can now handle any post type. The $post_type parameter has been added in WP 3.0.
-
Wordpress:按标题排序的get_attached_media('image')(Wordpress: get_attached_media('image') sorted by title)[2023-12-31]
获取已经订购的附件而不是排序结果数组会更好,对吗? 这将节省您的代码,头痛和处理。 如果你看看WP Codex, get_attached_media()调用get_children() ,它调用get_posts() (是的,快速升级)。 在WordPress中,附件(几乎任何东西)本质上都是一个post 。 考虑到所有这些,这应该会获取附加到按标题排序的帖子的图像列表 : $media = get_posts(array( 'post_parent' => get_the_ID(), ' ... -
尝试这个:
-
在wordpress中使用内置函数来包含文件: - 提供header.php它会带来它。 ID), array( 2600,1000 ), false, '' );?>使用过滤器操纵帖子标题。 function change_post_title( $title, $id = null ) { if ( is_single() ) { $title = 'new title'; } return $title; } add_filter( 'the_title', 'change_post_title', 10, 2 ); Thanks all for your help. I have used a filter but ...add_filter('the_title', 'change_title', 10, 2); function change_title($title, $id) { if (get_post_type($id) == "post") $title = 'Posted: ' . $title; return $title; } 请享用 add_filter('the_title', 'change_title', 10, 2); function change_title( ...
有没有办法从帖子标题中获取WordPress类别名称?(Is there any way to get a WordPress category name from the post title?)[2022-09-02]
编辑2 这是一个修改后的选择查询,根据术语是否在标题中,将术语与帖子匹配: select p.id, tt.term_taxonomy_id, t.term_id, t.name, p.post_title from wp_terms t join wp_posts p on INSTR(p.post_title, t.name) join wp_term_taxonomy tt on tt.term_id = t.term_id where p.post_type = 'post' 下面是您要使用 ...修剪Wordpress帖子标题(Trim Wordpress Post Title)[2023-04-16]
你可以使用正则表达式 /(.{3}).*(\..{2,4})/ 这会捕获前三个字符(.{3}) 。 然后忽略一切, .* 直到最后一个时期和接下来的2-4个字符(对于ai , mpeg , jpg可以将其过滤为3如果它总是3), \..{2,4} 。 .{2,4}位是2-4个字符串长的任何字符。 PHP用法: $wp_attached_file = 'sssssssssssssssssssssssssssssssssssssssssssss.txt'; echo preg_replace('/(.{3}) ...保持你的代码只在一个div.apply背景图像中打印标题到这个div。 然后在这个div中使用尽可能多的图像,图像不应该分解。 keep your code which prints title in a single div.apply background image to this div only. then inside this div use as many < br >, the image should not breakup.WordPress帖子标题+后缀(WordPress Post Title + suffix)[2022-03-18]
您可以保存两个帖子标题相同的帖子。 添加到帖子标题的数字实际上不是标题的标题。 如果你想用数字标题,那么这将对你有所帮助 global $post; echo $post->post_name; or $sql = "select * from wp_posts where post_title='test'; $post = $wpdb->get_row($sql); echo $post->post_name; You can save two posts with same post ...相关文章
更多- spellcheck
- solrj实现solr的suggestion(基于spellcheck)
- Solr拼写检查(spellCheck)配置和使用
- Java-based 实现的索引复制
- solr学习之(四)_solr4.2.0版本的spellCheck功能的实现
- Solr总结
- Apache Solr3.4应用实践(高亮 拼写检查 匹配相似)
- Solr调研总结
- Scaling Lucene and Solr
- solr与lucene
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)