首页 \ 问答 \ Solr:操纵查询字符串(Solr: manipulate query string)

Solr:操纵查询字符串(Solr: manipulate query string)

如何操作发送给Solr的查询字符串?

例如,有人输入“stackoverflow-version1.0”,但没有找到结果。 但是,如果查询只是“stackoverflow”,那么搜索就会成功。 所以我想截断“ - ”并再次搜索第一部分。

一些研究将我带到了solr.PatternReplaceCharFilterFactory类。 我将它包含在我的schema.xml中,如下所示。 有谁看到,为什么我的查询仍然没有产生任何结果? 我应该使用的其他课程?

更新:现在我的代码如下所示:

<fieldType name="ngram" class="solr.TextField" omitNorms="true">
  <analyzer type="index">
    <tokenizer class="solr.NGramTokenizerFactory" minGramSize="1" maxGramSize="20" />
    <filter class="solr.WordDelimiterFilterFactory"
      generateWordParts="1"
      splitOnNumerics="0"
      generateNumberParts="0"
      catenateWords="0"
      catenateNumbers="0"
      catenateAll="0"
      preserveOriginal="1"
    />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.ASCIIFoldingFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.WordDelimiterFilterFactory"
      generateWordParts="1"
      generateNumberParts="0"
      splitOnNumerics="0"
      catenateWords="0"
      catenateNumbers="0"
      catenateAll="0"
      preserveOriginal="1"
    />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.ASCIIFoldingFilterFactory"/>
  </analyzer>
</fieldType>

运行分析仪它给了我这个: 在此处输入图像描述

在这里查询UI: 在此处输入图像描述


How can I manipulate query strings that are sent to Solr?

For example, someone enters "stackoverflow-version1.0" but there will be no results found. However if the query was only "stackoverflow" the search would have been successful. So I want to truncate at "-" and search again for the first part.

Some research brought me to the solr.PatternReplaceCharFilterFactory class. I included it as shown below in my schema.xml. Does anyone see, why my query still does not yield any results? Any other classes I should use?

UPDATE: Now my code looks like follows:

<fieldType name="ngram" class="solr.TextField" omitNorms="true">
  <analyzer type="index">
    <tokenizer class="solr.NGramTokenizerFactory" minGramSize="1" maxGramSize="20" />
    <filter class="solr.WordDelimiterFilterFactory"
      generateWordParts="1"
      splitOnNumerics="0"
      generateNumberParts="0"
      catenateWords="0"
      catenateNumbers="0"
      catenateAll="0"
      preserveOriginal="1"
    />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.ASCIIFoldingFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.WordDelimiterFilterFactory"
      generateWordParts="1"
      generateNumberParts="0"
      splitOnNumerics="0"
      catenateWords="0"
      catenateNumbers="0"
      catenateAll="0"
      preserveOriginal="1"
    />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.ASCIIFoldingFilterFactory"/>
  </analyzer>
</fieldType>

Running the analyzer it gives me this: enter image description here

And here the query UI:enter image description here


原文:https://stackoverflow.com/questions/35797757
更新时间:2023-12-24 22:12

最满意答案

容易...根据这篇文章[如何]从终端启动应用程序?

String jsflPath = "/var/...tmp/sample.jsfl";    
File jsflFile = new File(jsflPath);
jsflFile.setExecutable(true);
String[] commands = new String[]{"open", jsflFile.getAbsolutePath() };

ProcessBuilder pb = new ProcessBuilder(commands);
pb.start();

要么

String[] commands = new String[]{"open", "-a", "Adobe Flash CS5", jsflFile.getAbsolutePath()};

Easy... according to this article [HOW TO] Launch Application from Terminal?

String jsflPath = "/var/...tmp/sample.jsfl";    
File jsflFile = new File(jsflPath);
jsflFile.setExecutable(true);
String[] commands = new String[]{"open", jsflFile.getAbsolutePath() };

ProcessBuilder pb = new ProcessBuilder(commands);
pb.start();

or

String[] commands = new String[]{"open", "-a", "Adobe Flash CS5", jsflFile.getAbsolutePath()};

相关问答

更多
  • 在回答之前先向楼上童鞋致以严重的鄙视.. 两者的功能完全一样,只是面向的系统板本不一样.有combo的可以从任何版本的Leopard更新到目标版本,而没有combo的必须从上一版本更新.简单吧~
  • 从苹果开发人员连接 : Preferences API生成的首选项文件名为com.apple.java.util.prefs 。 用户的首选项文件存储在其主目录( ~/Library/Preferences/ )中。 系统首选项存储在/Library/Preferences/ ,如果用户是管理员,则只会将其保留在磁盘中。 From Apple Developer Connection: The preferences files generated by the Preferences API are na ...
  • 转到下面的链接并下载Java for OS X 2014-001 http://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US 希望安装它后,它将工作 Go to the link below and download Java for OS X 2014-001 http://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US Hopefully after installi ...
  • 容易...根据这篇文章[如何]从终端启动应用程序? String jsflPath = "/var/...tmp/sample.jsfl"; File jsflFile = new File(jsflPath); jsflFile.setExecutable(true); String[] commands = new String[]{"open", jsflFile.getAbsolutePath() }; ProcessBuilder pb = new ProcessBuilder(comm ...
  • 可能你的系统类路径以某种方式受到2.5之前的servlet API jar的污染。 您可以通过运行java javax.servlet.http.HttpServlet来检查它 - 它应该抛出NoClassDefFound 。 如果它抛出NoSuchMethodError ,请检查您的类路径(尤其是JRE安装的CLASSPATH环境变量和lib/ext子文件夹)。 编辑 :尝试以下代码 - 至少它将显示违规jar的位置: public class Test { public static void ...
  • 在Leopard上,打开/Applications/Utilities/Java/Java Preferences.app ,并选择Java 6作为applet的默认值。 当然,如果你没有运行Leopard的英特尔Mac(至少,我认为它需要Leopard ......也许有Tiger的安装程序),这将无效。 在任何一种情况下,如果您需要为用户部署基于1.6的applet,则不可靠,但为您自己的冲浪工作。 It was a problem with OSX itself that didn't support ...
  • Mac上Java的未来很好。 Apple将他们的代码贡献给OpenJDK项目,该项目还启动了一个项目(启动Java 7)来构建Mac的二进制文件。 因此,在不久的将来,我们的Mac用户将能够安装JRE和JDK,就像Windows和Linux用户一样。 在这里和这里阅读。 The future of Java on Mac is fine. Apple is contributing their code to the OpenJDK project, which has also started a pro ...
  • 确保没有运行Jenkins或Tomcat的其他实例( sudo ps -ef | grep jenkins或sudo ps -ef | grep java ) sudo netstat -a | grep LISTEN sudo netstat -a | grep LISTEN查看哪些进程正在侦听端口 使用不同的端口java -jar jenkins.jar --httpPort Make sure there are no other instances of Jenkins ...
  • 从Java调用osascriptWrapper.sh脚本: Runtime.getRuntime().exec("/path/to/osascriptWrapper.sh myjar.jar"); 将osascriptWrapper.sh定义为: #!/bin/bash osascript -e "do shell script \"/path2/to2/runJar.sh $*\" with administrator privileges" 和runJar.sh: #!/bin/bash jav ...
  • 看一下apple的OSXAdapter包 (链接需要免费的苹果开发人员登录)进行java开发。 包中包含的示例向您展示了如何以仅在应用程序在OS X下运行时激活的方式很好地集成到OS X应用程序菜单。 This seems to work on Mac OS X Leopard, with no change to the original application. So I've lost interest in the answer (to how to make it work on Tiger). ...

相关文章

更多

最新问答

更多
  • 您如何使用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)