首页 \ 问答 \ Solr拼写检查器没有返回任何结果(Solr spellchecker not returning any results)

Solr拼写检查器没有返回任何结果(Solr spellchecker not returning any results)

我正在开发一个需要我第一次使用Solr的应用程序。 我设置了它,索引正确的数据,并按照我的意愿查询,但我似乎无法让拼写检查组件正常工作。 无论我查询什么,拼写检查器都不会返回任何建议。 我已经包含了solrconfig和schema.xml的相关部分。

schema.xml中

<fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
  <analyzer type="index">
    <charFilter class="solr.HTMLStripCharFilterFactory"/>
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StandardFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true"  expand="true"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StandardFilterFactory"/>
  </analyzer>
</fieldType>

<!-- CUT -->

<field name="spell" type="textSpell" indexed="true" stored="true" />

solrconfig.xml中

<requestHandler name="/select" class="solr.SearchHandler">
   <lst name="defaults">
     <str name="defType">edismax</str>
     <str name="spellcheck.dictionary">default</str>
     <str name="spellcheck.onlyMorePopular">false</str>
     <!-- <str name="spellcheck.extendedResults">false</str> -->
     <str name="spellcheck.count">3</str>

    <str name="qf">
      frontlist_flapcopy^0.5 title^2.0  subtitle^1.0 series^1.5 author^3.0 frontlist_ean^6.0
    </str>
    <str name="pf">
      frontlist_flapcopy^0.5 title^2.0  subtitle^1.0 series^1.5 author^3.0 frontlist_ean^6.0
    </str>
    <str name="fl">
      title,subtitle,series,author,eans,formats,prices,frontlist_ean,onsaledate,imprint,frontlist_flapcopy
    </str>
    <str name="mm">
      2&lt;-1 5&lt;-2 6&lt;90%
    </str>
    <int name="ps">100</int>
    <bool name="hl">true</bool>
    <str name="q.alt">*:*</str>
    <str name="hl.fl">title,subtitle,series,author,frontlist_flapcopy</str>
    <str name="f.title.hl.fragsize">0</str>
    <str name="f.title.hl.alternateField">title</str>
    <str name="f.subtitle.hl.fragsize">0</str>
    <str name="f.subtitle.hl.alternateField">url</str>
    <str name="f.series.hl.fragsize">0</str>
    <str name="f.series.hl.alternateField">url</str>
    <str name="f.author.hl.fragsize">0</str>
    <str name="f.author.hl.alternateField">url</str>
    <str name="f.frontlist_flapcopy.hl.fragsize">0</str>
    <str name="f.frontlist_flapcopy.hl.alternateField">url</str>

    <str name="echoParams">explicit</str>
    <float name="accuracy">0.7</float>
   </lst>

   <lst name="appends">
       <str name="fq">forsaleinusa:true</str>
   </lst>
   <arr name="last-components">
      <str>spellcheck</str>
   </arr>
</requestHandler>

<!-- CUT -->

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
  <lst name="spellchecker">
    <str name="name">default</str>
    <str name="classname">solr.IndexBasedSpellChecker</str>
    <str name="field">spell</str>
    <str name="spellcheckIndexDir">/path/to/my/spell/index</str>
    <str name="accuracy">0.7</str>
    <float name="thresholdTokenFrequency">.0001</float>
  </lst>

  <lst name="spellchecker">
    <str name="name">jarowinkler</str>
    <str name="classname">solr.IndexBasedSpellChecker</str>
    <str name="field">spell</str>
    <str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
    <str name="spellcheckIndexDir">/path/to/my/spell/index</str>
  </lst>

  <str name="queryAnalyzerFieldType">textSpell</str>
</searchComponent>

当我转到http://localhost:8983/solr/select/?q=query&spellcheck.build=true然后查看/ path / to / my / spell / index中生成的文件,有一个segments.gen和一个segments_1,两者都只包含几个字节的二进制数据。 然后,当我输入一个查询并将&spellcheck=true附加到查询字符串时,无论我的查询是什么,我都不会得到任何建议:

<lst name="spellcheck">
  <lst name="suggestions"/>
</lst>

知道这里发生了什么吗?


I am working on an application that requires me to use Solr for the first time. I got it set up, indexing the correct data, and querying as I would like it, but I cannot seem to get the spellcheck component working properly. No matter what I query, the spellchecker will not return any suggestions. I have included the relevant parts of my solrconfig and schema.xml.

schema.xml

<fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
  <analyzer type="index">
    <charFilter class="solr.HTMLStripCharFilterFactory"/>
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StandardFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true"  expand="true"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StandardFilterFactory"/>
  </analyzer>
</fieldType>

<!-- CUT -->

<field name="spell" type="textSpell" indexed="true" stored="true" />

solrconfig.xml

<requestHandler name="/select" class="solr.SearchHandler">
   <lst name="defaults">
     <str name="defType">edismax</str>
     <str name="spellcheck.dictionary">default</str>
     <str name="spellcheck.onlyMorePopular">false</str>
     <!-- <str name="spellcheck.extendedResults">false</str> -->
     <str name="spellcheck.count">3</str>

    <str name="qf">
      frontlist_flapcopy^0.5 title^2.0  subtitle^1.0 series^1.5 author^3.0 frontlist_ean^6.0
    </str>
    <str name="pf">
      frontlist_flapcopy^0.5 title^2.0  subtitle^1.0 series^1.5 author^3.0 frontlist_ean^6.0
    </str>
    <str name="fl">
      title,subtitle,series,author,eans,formats,prices,frontlist_ean,onsaledate,imprint,frontlist_flapcopy
    </str>
    <str name="mm">
      2&lt;-1 5&lt;-2 6&lt;90%
    </str>
    <int name="ps">100</int>
    <bool name="hl">true</bool>
    <str name="q.alt">*:*</str>
    <str name="hl.fl">title,subtitle,series,author,frontlist_flapcopy</str>
    <str name="f.title.hl.fragsize">0</str>
    <str name="f.title.hl.alternateField">title</str>
    <str name="f.subtitle.hl.fragsize">0</str>
    <str name="f.subtitle.hl.alternateField">url</str>
    <str name="f.series.hl.fragsize">0</str>
    <str name="f.series.hl.alternateField">url</str>
    <str name="f.author.hl.fragsize">0</str>
    <str name="f.author.hl.alternateField">url</str>
    <str name="f.frontlist_flapcopy.hl.fragsize">0</str>
    <str name="f.frontlist_flapcopy.hl.alternateField">url</str>

    <str name="echoParams">explicit</str>
    <float name="accuracy">0.7</float>
   </lst>

   <lst name="appends">
       <str name="fq">forsaleinusa:true</str>
   </lst>
   <arr name="last-components">
      <str>spellcheck</str>
   </arr>
</requestHandler>

<!-- CUT -->

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
  <lst name="spellchecker">
    <str name="name">default</str>
    <str name="classname">solr.IndexBasedSpellChecker</str>
    <str name="field">spell</str>
    <str name="spellcheckIndexDir">/path/to/my/spell/index</str>
    <str name="accuracy">0.7</str>
    <float name="thresholdTokenFrequency">.0001</float>
  </lst>

  <lst name="spellchecker">
    <str name="name">jarowinkler</str>
    <str name="classname">solr.IndexBasedSpellChecker</str>
    <str name="field">spell</str>
    <str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
    <str name="spellcheckIndexDir">/path/to/my/spell/index</str>
  </lst>

  <str name="queryAnalyzerFieldType">textSpell</str>
</searchComponent>

When I go to http://localhost:8983/solr/select/?q=query&spellcheck.build=true then look at the files generated in /path/to/my/spell/index, there is a segments.gen and a segments_1, both of which contain only a few bytes of binary data. Then, when I enter a query and append &spellcheck=true to the query string, I get no suggestions, no matter my query:

<lst name="spellcheck">
  <lst name="suggestions"/>
</lst>

Any idea what is going on here?


原文:https://stackoverflow.com/questions/11110352
更新时间:2023-04-03 13:04

最满意答案

要处理鼠标悬停在非客户区域上,您可以在WndProc捕获WM_NCMOUSEHOVER 。 如文档中所述,悬停跟踪会在生成此消息时停止。 如果应用程序需要进一步跟踪鼠标悬停行为,则必须再次调用TrackMouseEvent

NonClientMouseHover事件实现

在下面的代码中,通过捕获WM_NCMOUSEHOVER引发了NonClientMouseHover 。 您可以像处理NonClientMouseHover任何其他事件一样处理NonClientMouseHover事件:

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class SampleForm : Form
{
    [DllImport("user32.dll")]
    private static extern int TrackMouseEvent(ref TRACK_MOUSE_EVENT lpEventTrack);
    [StructLayout(LayoutKind.Sequential)]
    private struct TRACK_MOUSE_EVENT {
        public uint cbSize;
        public uint dwFlags;
        public IntPtr hwndTrack;
        public uint dwHoverTime;
        public static readonly TRACK_MOUSE_EVENT Empty;
    }
    private TRACK_MOUSE_EVENT track = TRACK_MOUSE_EVENT.Empty;
    const int WM_NCMOUSEMOVE = 0xA0;
    const int WM_NCMOUSEHOVER = 0x2A0;
    const int TME_HOVER = 0x1;
    const int TME_NONCLIENT = 0x10;
    public event EventHandler NonClientMouseHover;
    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);
        if (m.Msg == WM_NCMOUSEMOVE) {
            track.hwndTrack = this.Handle;
            track.cbSize = (uint)Marshal.SizeOf(track);
            track.dwFlags = TME_HOVER | TME_NONCLIENT;
            track.dwHoverTime = 500;
            TrackMouseEvent(ref track);
        }
        if (m.Msg == WM_NCMOUSEHOVER) {
            var handler = NonClientMouseHover;
            if (handler != null)
                NonClientMouseHover(this, EventArgs.Empty);
        }
    }
}

根据您的问题,您似乎对该事件感兴趣的是最小化的mdi子窗口。 该事件还会针对最小化的mdi子窗体进行提升,因此如果出于任何原因想要在鼠标悬停最小化的mdi子标题栏时执行某些操作,则可以检查if(((Form)sender).WindowState== FormWindowState.Minimized) 。 另外((Form)sender).Text是引发事件的表单的文本。

public partial class Form1 : Form
{
    ToolTip toolTip1 = new ToolTip();
    public Form1()
    {
        //InitializeComponent();
        this.Text = "Form1";
        this.IsMdiContainer = true;
        var f1 = new SampleForm() { Text = "Some Form", MdiParent = this };
        f1.NonClientMouseHover += child_NonClientMouseHover;
        f1.Show();
        var f2 = new SampleForm() { Text = "Some Other Form", MdiParent = this };
        f2.NonClientMouseHover += child_NonClientMouseHover;
        f2.Show();
    }
    void child_NonClientMouseHover(object sender, EventArgs e)
    {
        var f = (Form)sender;
        var p = f.PointToClient(f.Parent.PointToScreen(f.Location));
        p.Offset(0, -24);
        toolTip1.Show(f.Text, f, p, 2000);
    }
    protected override void OnFormClosed(FormClosedEventArgs e)
    {
        toolTip1.Dispose();
        base.OnFormClosed(e);
    }
}

在此处输入图像描述

注意:感谢鲍勃 在这里发帖。 处理WM_NCMOUSEHOVER的初始代码已经从那里开始,并使用了一些更改并删除了一些部分。


To handle a mouse hover over non-client area, you can trap WM_NCMOUSEHOVER in WndProc. As mentioned in documentations hover tracking stops when this message is generated. The application must call TrackMouseEvent again if it requires further tracking of mouse hover behavior.

NonClientMouseHover Event Implementation

In below code, a NonClientMouseHover has been raised by trapping WM_NCMOUSEHOVER. You can handle NonClientMouseHover event like any other events of the form:

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class SampleForm : Form
{
    [DllImport("user32.dll")]
    private static extern int TrackMouseEvent(ref TRACK_MOUSE_EVENT lpEventTrack);
    [StructLayout(LayoutKind.Sequential)]
    private struct TRACK_MOUSE_EVENT {
        public uint cbSize;
        public uint dwFlags;
        public IntPtr hwndTrack;
        public uint dwHoverTime;
        public static readonly TRACK_MOUSE_EVENT Empty;
    }
    private TRACK_MOUSE_EVENT track = TRACK_MOUSE_EVENT.Empty;
    const int WM_NCMOUSEMOVE = 0xA0;
    const int WM_NCMOUSEHOVER = 0x2A0;
    const int TME_HOVER = 0x1;
    const int TME_NONCLIENT = 0x10;
    public event EventHandler NonClientMouseHover;
    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);
        if (m.Msg == WM_NCMOUSEMOVE) {
            track.hwndTrack = this.Handle;
            track.cbSize = (uint)Marshal.SizeOf(track);
            track.dwFlags = TME_HOVER | TME_NONCLIENT;
            track.dwHoverTime = 500;
            TrackMouseEvent(ref track);
        }
        if (m.Msg == WM_NCMOUSEHOVER) {
            var handler = NonClientMouseHover;
            if (handler != null)
                NonClientMouseHover(this, EventArgs.Empty);
        }
    }
}

Example

Based on your question it seems you are interested to the event for a minimized mdi child window. The event also raises for a minimized mdi child form, so if for any reason you want to do something when the mouse hover title bar of a minimized mdi child, you can check if(((Form)sender).WindowState== FormWindowState.Minimized). Also ((Form)sender).Text is text of the form which raised the event.

public partial class Form1 : Form
{
    ToolTip toolTip1 = new ToolTip();
    public Form1()
    {
        //InitializeComponent();
        this.Text = "Form1";
        this.IsMdiContainer = true;
        var f1 = new SampleForm() { Text = "Some Form", MdiParent = this };
        f1.NonClientMouseHover += child_NonClientMouseHover;
        f1.Show();
        var f2 = new SampleForm() { Text = "Some Other Form", MdiParent = this };
        f2.NonClientMouseHover += child_NonClientMouseHover;
        f2.Show();
    }
    void child_NonClientMouseHover(object sender, EventArgs e)
    {
        var f = (Form)sender;
        var p = f.PointToClient(f.Parent.PointToScreen(f.Location));
        p.Offset(0, -24);
        toolTip1.Show(f.Text, f, p, 2000);
    }
    protected override void OnFormClosed(FormClosedEventArgs e)
    {
        toolTip1.Dispose();
        base.OnFormClosed(e);
    }
}

enter image description here

Note: Thanks to Bob for his post here. The initial code for handling WM_NCMOUSEHOVER has taken from there and made working with some changes and removing some parts.

相关问答

更多

相关文章

更多

最新问答

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