我写了一个TokenFilter在流中添加令牌的.
如果有人能够阐明语义,我将不胜感激.特别是在(*)恢复状态时,这是否意味着我们要么覆盖当前令牌,要么在捕获状态之前创建令牌?
这大致就是我所做的
private final LinkedList<String> extraTokens = new LinkedList<String>();
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
private State savedState;
@Override
public boolean incrementToken() throws IOException {
if (!extraTokens.isEmpty()) {
// Do we not loose/overwrite the current termAtt token here? (*)
restoreState(savedState);
termAtt.setEmpty().append(extraTokens.remove());
return true;
}
if (input.incrementToken()) {
if (/* condition */) {
extraTokens.add("fo");
savedState = captureState();
}
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
这是否意味着,对于空白标记化字符串的输入流 "a b c"
(a) -> (b) -> (c) -> ... …Run Code Online (Sandbox Code Playgroud) 我一直在使用solr 3,现在我打算切换到solr 4.我想运行solr的端口是9090而不是8080.AFAIK,更改我们配置solr.xml文件的端口号.我的solr.xml文件中的条目如下所示:
<cores adminPath="/admin/cores" defaultCoreName="collection1" host="${host:}" hostPort="9090" hostContext="${hostContext:solr}" zkClientTimeout="${zkClientTimeout:15000}">
<core name="collection1" instanceDir="collection1" />
Run Code Online (Sandbox Code Playgroud)
令人惊讶的是,当我点击网址时:http:// [domain]:9090/solr/admin ..它说找不到页面,但http:// [domain]:8983/solr /> ..只是工作即使在更改端口号后也可以.我确信我错过了一些东西.有人可以帮我这个吗?
谢谢.
我使用solrj作为客户端来索引solr服务器上的文档.
我在从solr服务器删除'id'索引时遇到问题.我使用以下代码删除索引:
server.deleteById("id:20");
server.commit(true,true);
Run Code Online (Sandbox Code Playgroud)
在此之后,当我再次搜索文档时,搜索结果也包含上述文档.不知道这段代码出了什么问题.请帮我解决问题.
谢谢!
在尝试从Solr 4.3.0升级到Solr 4.4.0时,我遇到了这个异常:
java.lang.IllegalArgumentException: enablePositionIncrements=false is not supported anymore as of Lucene 4.4 as it can create broken token streams
Run Code Online (Sandbox Code Playgroud)
这让我想到了这个问题.我需要能够匹配查询,而不管插入的停用词(曾经使用enablePositionIncrements ="true").例如:"条形图的foo"会找到与"foo bar","foo of bar"和"foo of the bar"相匹配的文档.在4.4.0中不推荐使用此选项我不清楚如何保持相同的功能.
该包的Javadoc补充说:
如果所选分析器过滤停用词"是"和"该",那么对于包含字符串"蓝色是天空"的文档,只有标记"蓝色","天空"被索引,位置("天空") = 3 +位置("蓝色").现在,短语查询"蓝色是天空"会找到该文档,因为同一个分析器会从该查询中过滤相同的停用词.但是短语查询"蓝天"将找不到该文档,因为"蓝色"和"天空"之间的位置增量仅为1.
如果此行为不符合应用程序需求,则需要将查询解析器配置为在生成短语查询时不考虑位置增量.
但是没有提到如何实际配置查询解析器来执行此操作.当Solr走向5.0时,有谁知道如何处理这个问题?
我正在使用apache solr来获取我的webapp的匹配功能,我遇到了这种情况的问题:
我有三个程序员,技能领域是他们的技能,"重量"意味着他/她的技能有多好:
{
name: "John",
skill: [
{name: "java", weight: 90},
{name: "oracle", weight: 90},
{name: "linux", weight: 70}
]
},
{
name: "Sam",
skill: [
{name: "C#", weight: 98},
{name: "java", weight: 75},
{name: "oracle", weight: 70},
{name: "tomcat", weight: 70},
]
},
{
name: "Bob",
skill: [
{name: "oracle", weight: 90},
{name: "java", weight: 85}
]
}
Run Code Online (Sandbox Code Playgroud)
我找工作的程序员:
{
name: "webapp development",
skillRequired: [
{name: "java", weight: 85},
{name: "oracle", weight: 85},
]
}
Run Code Online (Sandbox Code Playgroud)
我想用这份工作的"技能要求"来匹配那些程序员(找到最适合这份工作的人).在这种情况下,应该是John和Bob,Sam因为他的java和oracle技能不够好而被踢掉了.约翰应该比鲍勃得分更高,因为他更了解甲骨文.
问题是,solr无法索引嵌套对象,我认为我能得到的最佳格式是:
name: …Run Code Online (Sandbox Code Playgroud) 我试过precisionStep在几个地方理解,但不能完全理解它的概念.所以,请用非常简单的话来解释它的含义.
我想从solr中搜索数据,如下所示
这是我的两张桌子:


那我怎么能用solr做这个日期搜索....
编辑
我使用SolrPhpClient进行此操作.
这是我的schema.xml中的字段:
<fields>
<field name="id" type="string" indexed="true" stored="true" required="true"/>
<field name="event_name" type="text_general" indexed="true" stored="true"/>
<field name="event_category_id" type="string" indexed="true" stored="true"/>
<field name="cat_name" type="text_general" indexed="true" stored="true"/>
<field name="event_sub_category_id" type="string" indexed="true" stored="true"/>
<field name="sub_cat_name" type="text_general" indexed="true" stored="true"/>
<field name="event_location" type="text_general" indexed="true" stored="true"/>
<field name="org_id" type="string" indexed="false" stored="true"/>
<field name="org_name" type="text_general" indexed="true" stored="true"/>
<field name="event_city" type="text_general" indexed="true" stored="true"/>
<field name="multiple_tags" type="text_general" indexed="true" stored="true" multiValued="true" />
<field name="multiple_start_dates" type="date" indexed="true" stored="true" multiValued="true" />
<field name="event_twitter_url" type="text_general" indexed="false" stored="true"/>
<field name="event_fb_url" type="text_general" …Run Code Online (Sandbox Code Playgroud) 如何使用JSON更新Solr 4.5.1中的多个文档?我试过这个,但它不起作用:
POST /solr/mycore/update/json:
{
"commit": {},
"add": {
"overwrite": true,
"doc": [{
"thumbnail": "/images/404.png",
"url": "/404.html?1",
"id": "demo:/404.html?1",
"channel": "demo",
"display_name": "One entry",
"description": "One entry is not enough."
}, {
"thumbnail": "/images/404.png",
"url": "/404.html?2",
"id": "demo:/404.html?2",
"channel": "demo",
"display_name": "Another entry",
"description": "Another entry is required."
}
]
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将标准4.x Solr安装升级到Solr云5.xI在两者之间进行了一些性能测试,发现了巨大的差异.在同一台服务器上,在不同的时间,我运行了以下内容:
两者都有相同的数据
在多次执行示例查询时,平均结果是标准Solr比Solr云快5倍.
dataimport处理程序也比标准solr快2倍.
有什么想法为什么这种差异以及如何提高solrcloud性能?
我有一个像这样的Solr文档,其中所有字段都映射为单个文档.
<doc>
<int name="Id">7</int>
<str name="Name">PersonName</str>
<str name="Address">Address Line 1, Address Line 2, City</str>
<str name="Country">India</str>
<str name="ImageURL">0000028415.jpeg</str>
<arr name="Category">
<str>Student</str>
<str>Group A</str>
</arr>
</doc>
Run Code Online (Sandbox Code Playgroud)
我们希望对其进行规范化,并为Person,Country和Category分别提供doc类型.
<doc>
<int name="PId">7</int>
<str name="Name">PersonName</str>
<str name="Address">Address Line 1, Address Line 2, City</str>
<str name="CountryId">91</str>
<str name="ImageURL">0000028415.jpeg</str>
<arr name="CategoryId">
<str>2</str>
<str>5</str>
</arr>
</doc>
<doc>
<int name="CId">91</int>
<str name="CountryName">India</str>
</doc>
<doc>
<int name="CatId">2</int>
<str name="CategoryName">Student</str>
</doc>
Run Code Online (Sandbox Code Playgroud)
请注意,我只是简化了示例,我使用的实际文档比这复杂得多,并且索引中有数百万个文档.
我想了解,如何使用这种文档结构加入并进行过滤查询.与之前的情况相比,它如何影响性能,其中所有细节都存储在单个doc结构中.
更新
具有当前结构的示例查询,希望这有助于了解当前如何完成它:
以下是应用了某些方面的搜索示例查询 -
/select?indent=on&wt=json&facet.field={!ex%3DCategory}Category&facet.field=Manufacturer&facet.field=Vendor&facet.field=f_Hardrive&facet.field=f_Operating%2BSystem&facet.field=f_Memory&facet.field=f_CPU%2BType&facet.field=f_Screensize&facet.field=pa_OS&bf=&start=0&fq={!tag%3DCategory}Category:Notebooks&fq=Price:[0+TO+9999999999999]&rows=6&version=2.2&bq=&facet.query=AverageRating:[4+TO+5]&facet.query=AverageRating:[3+TO+5]&facet.query=AverageRating:[2+TO+5]&facet.query=AverageRating:[1+TO+5]&q=(laptop)&defType=edismax&spellcheck.q=(laptop)&qf=Name^7++ShortDescription^6++FullDescription^4+CategoryCopy^2+ManufacturerCopy^2+Sku^3+ChildSku^3+nGramContent+Attributes+ProductAttributes+Tag+ManufacturerPartNumber+CustomProperties&spellcheck=true&stats=true&facet.mincount=1&facet=true&spellcheck.collate=true&stats.field=Price
Run Code Online (Sandbox Code Playgroud)
这个带有facets的过滤器查询:
select?indent=on&wt=json&facet.field=f_Hardrive&facet.field=f_Operating%2BSystem&facet.field=f_Memory&facet.field=f_CPU%2BType&facet.field={!ex%3Df_Screensize}f_Screensize&facet.field=pa_HDD&facet.field=pa_OS&facet.field={!ex%3Dpa_OS}pa_OS&facet.field=pa_OS&facet.field=pa_Processor&facet.field=pa_RAM&facet.field=pa_Software&facet.field=Vendor&facet.field={!ex%3DManufacturer}Manufacturer&facet.field=Category&start=0&fq=StockAvailability:(true)&fq={!tag%3Df_Screensize}f_Screensize:15.0%2527%2527\!!4!!&fq={!tag%3Dpa_OS}pa_OS:Apple\!!0!!&fq={!tag%3DPrice}Price:[594+TO+1800]&sort=CDO_1+asc&rows=6&version=2.2&facet.query=AverageRating:[4+TO+5]&facet.query=AverageRating:[3+TO+5]&facet.query=AverageRating:[2+TO+5]&facet.query=AverageRating:[1+TO+5]&q=CategoryID:(1+OR+2+OR+3+OR+4)&defType=edismax&spellcheck=true&stats=true&facet.mincount=1&facet=true&spellcheck.collate=true&stats.field=Price
Run Code Online (Sandbox Code Playgroud)