- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试在文本中包含多个单词(AND 运算)不会丢失词干。
例如:
db.supplies.runCommand("text", {search:"printers inks"})应使用 (printer and ink) 或 (printers ink) 或 (printers ink) 或 (printers inks) 返回结果,而不是使用打印机或墨水的所有结果。
这篇文章涵盖了作为 AND 操作搜索多个词,但解决方案不搜索词干词 -> MongoDB Text Search AND multiple search words .
我能想到的唯一方法是创建所有单词的排列,然后搜索排列的数量(可能很大)
这可能不是搜索大型集合的有效方法。
是否有更好、更智能的方法来做到这一点?
最佳答案
那么您是否有理由必须使用文本搜索?如果是我,我会使用正则表达式。
https://docs.mongodb.com/manual/reference/operator/query/regex/
像这样的事情在我的脑海中浮现。
db.collection.find({products:/printers inks|printers|inks/})
现在我想您也可以通过文本搜索来做同样的事情。
db.collection.find({$text:{$search : "\"printers inks\" printers inks"}})
注意转义引号。
关于MongoDB 文本搜索和具有词干提取的多个搜索词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46333721/
我想搜索一个单词及其在句子中的变体。例如,单词“happy”的变体是“happiest”、“happier”。有java库支持吗? 最佳答案 您可以使用Porter stemming algorith
愚蠢的,但我无法访问 NLTK 中的主干函数。 我打电话 import nltk nltk.stem.porter.step1ab() 但我被告知该对象没有 step1ab 属性。我想我以某种方式没有
我想将 DataFrame 的列和索引限制为这样的内容 ps = PorterStemmer() df_dic = pd.read_csv('inquirerbasic_clean.csv', sep
查看以下脚本tortest.py,它反复切换TOR电路并检查IP地址是否已更改: #!/usr/bin/env python2.7 # -*- coding: utf-8 -*- import jso
我是一名优秀的程序员,十分优秀!