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<-1 5<-2 6<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<-1 5<-2 6<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
最满意答案
要处理鼠标悬停在非客户区域上,您可以在
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
inWndProc
. As mentioned in documentations hover tracking stops when this message is generated. The application must callTrackMouseEvent
again if it requires further tracking of mouse hover behavior.NonClientMouseHover Event Implementation
In below code, a
NonClientMouseHover
has been raised by trappingWM_NCMOUSEHOVER
. You can handleNonClientMouseHover
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); } }
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.
相关问答
更多-
如何从父窗体标题栏中删除MDI子文本?(How to remove the MDI child text from the parent form title bar? C# .NET)[2021-10-14]
您可以将子窗口的Form.Text属性更改为空字符串,这样标题栏将只显示“MainWindowTitle”。 You can change the Form.Text property of child windows to empty string, that way the titlebar will only display "MainWindowTitle". -
您需要提供属性data-trigger : data-trigger="hover" 试试这样的事: FIDDLE You need to provide attribute ...
-
当您调用Show()时,您将MdiParent传递给frmSpeedSearch。 因此,您可以这样做: Dim frm As New frmStorePage(_store) frm.MdiParent = Me.Owner frm.Show() You passed the MdiParent to frmSpeedSearch when you called Show(). As such, you can do: Dim frm As New frmStorePage(_store) frm.Md ...
-
不确定我是否从截图中看到了它。 但投诉是熟悉的。 MDI真的不喜欢最大化的子窗口。 当您显示一个新的子窗口并使其最大化时,它需要经历一场歌舞。 首先,它恢复当前的孩子,使其不再最大化。 然后创建新子项并将焦点设置为它。 然后最大化它。 这些中间步骤是可见的,并且在绘制儿童时可能产生大量的闪烁。 你看起来很贵。 你无法抑制这幅画。 如果始终显示最大化的MDI子窗口,则MDI是要使用的错误表单模型。 只需使用一个简单的表单,让孩子'windows'用户控件。 您甚至可以通过将其TopLevel属性设置为fals ...
-
尝试Form的Size_Changed事件,( Form1是MDI父级, TestForm (frm)是MDI子级) TestForm frm; private void Form1_Load(object sender, EventArgs e) { frm = new TestForm(); frm.MdiParent = this; frm.SizeChanged += Frm_SizeChanged; frm.Show(); } private void ...
-
Delphi MDI应用程序和MDI Children的标题栏(Delphi MDI Application and the titlebar of the MDI Children)[2024-01-19]
所有你需要的 - 重载程序CreateWindowHandle,如下所示: unit CHILDWIN; interface uses Windows, Classes, Graphics, Forms, Controls, StdCtrls; type TMDIChild = class(TForm) private { Private declarations } public { Public declarations } procedure CreateWind ... -
当我尝试时,对我来说工作正常: type TMDIChildForm = class(TForm) private { Private declarations } procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND; public { Public declarations } end; procedure TMDIChildForm.WMSysCommand(var Msg: ...
-
要处理鼠标悬停在非客户区域上,您可以在WndProc捕获WM_NCMOUSEHOVER 。 如文档中所述,悬停跟踪会在生成此消息时停止。 如果应用程序需要进一步跟踪鼠标悬停行为,则必须再次调用TrackMouseEvent 。 NonClientMouseHover事件实现 在下面的代码中,通过捕获WM_NCMOUSEHOVER引发了NonClientMouseHover 。 您可以像处理NonClientMouseHover任何其他事件一样处理NonClientMouseHover事件: using Sy ...
-
原生Windows MDI实现无法处理无边界MDI子窗口。 不幸的是,Winforms忘记执行这一限制。 您可以在Show()调用后移动WindowState赋值,但会导致另一个问题。 只是不要使其无边界,无论如何边界不可见。 The native Windows MDI implementation cannot deal with borderless MDI child windows. Unfortunately, Winforms forgets to enforce that restricti ...
-
如何从MDI父级中的最大化子项禁用自动生成的标题栏?(How to disable auto generated title bar from maximized child in MDI parent?)[2023-08-30]
我认为它可能是您表单上的控件框属性。 将此设置为false I think it might be the control box property on your form. Set this to false