我有一些具有相同内容的文档,但是当我尝试查询这些文档时,虽然查询字段包含相同的文本,但我获得了不同的分数.我已经解释了分数,但我无法分析并找到不同分数的原因.
我的疑问是
curl 'localhost:9200/acqindex/_search?pretty=1' -d '{
"explain" : true,
"query" : {
"query_string" : {
"query" : "text:shimla"
}
}
}'
Run Code Online (Sandbox Code Playgroud)
搜索回复:
{
"took" : 8,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 31208,
"max_score" : 268.85962,
"hits" : [ {
"_shard" : 0,
"_node" : "KOebAnGhSJKUHLPNxndcpQ",
"_index" : "acqindex",
"_type" : "autocomplete_questions",
"_id" : "50efec6c38cc6fdabd8653a3",
"_score" : 268.85962, "_source" : {"_class":"com.ixigo.next.cms.model.AutoCompleteObject","_id":"50efec6c38cc6fdabd8653a3","ad":"rajasthan,IN","category":["Destination"],"ctype":"destination","eid":"503b2a65e4b032e338f0d24b","po":8.772307692307692,"text":"shimla","url":"/travel-guide/shimla"},
"_explanation" : {
"value" …Run Code Online (Sandbox Code Playgroud) 我在ElasticSearch中有一个父子映射:
父:用户
孩子:特权
对于特权,有一些属性,一个是" privilegeName ".
查询返回具有某些特权的用户,但我想为每个用户返回与该查询匹配的特权的聚合特权名称has_child.我可以返回所有特权与inner_hits和处理他们在客户端,但可能是麻烦的.是否有可能聚合inner_hits?
谢谢
我有一个Mongodb群集,其中包含一个主副本和一个副本副本作为复制集一起运行.但随着流量的增长,我决定执行分片以获得更高的写入速度.
我根据本教程对"_id"列执行了散列分片,并将数据拆分为两个分片.然后,我进行了一些基准测试,发现在某些情况下,分片群集甚至比未散列群集更慢.
这是测试结果.
最大吞吐量测试:使用十台机器同时运行"mongoimport"将数据加载到目标数据库中,以测试db的最大写入速度.
结果:
分片群集可以插入39500个文档/秒.
未整数群集可以插入27400个文档/秒.
单实例mongoimport测试:只使用一台机器运行"mongoimport"将数据加载到目标数据库中.
结果:
分片群集可以插入14285个文档/秒.
未整数群集可以插入14085个文档/秒.
使用mongodb java驱动程序加载单实例数据:通过调用mongodb java驱动程序的api,只使用一个实例将数据加载到目标数据库中.
结果:
分片群集可以插入4630个文档.
未整数群集可以插入17544个文档/秒.
第一次测试的结果非常有意义.您将数据库分成2个分片群集,吞吐量增加了约50%,一切都很完美,万岁!
第二次测试有点道理.那么吞吐量大致相同,但可能是数据加载器方面的瓶颈,毕竟我们只用一个实例加载数据.
但第三次测试确实让我感到困惑.没有意义的是,分片群集可以比未受干扰的群集慢得多.另一方面,unsharded db具有惊人的速度,甚至比使用mongoimport加载数据更快.
用于加载数据的java代码粘贴在下面.我真的无法弄清楚这一点,并提前感谢所有答案.
public static void insert(String host, int port) throws FileNotFoundException,
InterruptedException, ExecutionException {
MongoClient mongoClient = new MongoClient(host, port);
mongoClient.setWriteConcern(WriteConcern.UNACKNOWLEDGED);
MongoDatabase database = mongoClient.getDatabase("my-db");
MongoCollection<Document> collection = database.getCollection("my-collection");
Scanner scan = new Scanner(new File("my-sample-dataset"));
// Pre-load the data into the memory, so that the db …Run Code Online (Sandbox Code Playgroud) try{
File file = new File("write.txt");
FileWriter writer = new FileWriter(file);
PrintWriter printWriter = new PrintWriter(writer);
printWriter.println("pqr");
printWriter.println("jkl");
printWriter.close();
PrintWriter printWriter = new PrintWriter(file);
printWriter.println("abc");
printWriter.println("xyz");
printWriter.close();
}
Run Code Online (Sandbox Code Playgroud)
我不明白这两种方式有什么区别.在哪种情况下我应该使用printWriter和fileWriter.
我正在尝试使用mongodb-river使用以下命令在elasticsearch中索引mongodb,但文档映射未生效.它仍然使用字段的默认分析器(标准)text
Mongodb-river 该文档指定索引的创建,但没有关于如何提供自定义映射的文档.这是我试过的.是否有任何其他文档,我可以找到如何使用mongodb-river指定自定义分析器等.
curl -XPUT "localhost:9200/_river/autocompleteindex/_meta" -d '
{
"type": "mongodb",
"mongodb": {
"host": "rahulg-dc",
"port": "27017",
"db": "qna",
"collection": "autocomplete_questions"
},
"index": {
"name": "autocompleteindex",
"type": "autocomplete_questions",
"analysis" : {
"analyzer" : {
"str_search_analyzer" : {
"tokenizer" : "keyword",
"filter" : ["lowercase"]
},
"str_index_analyzer" : {
"tokenizer" : "keyword",
"filter" : ["lowercase", "ngram"]
}
},
"filter" : {
"ngram" : {
"type" : "ngram",
"min_gram" : 2,
"max_gram" : 20
}
}
}
},
"autocompleteindex": {
"_boost" : …Run Code Online (Sandbox Code Playgroud) 方法返回应该如果输入一个数字,假设345,那么输出应该是3 + 4 + 5 = 12 - > 1 + 2 = 3.我在这里做错了什么?
public class DigitSum
{
int Sum=0;
public int compute( int MethParam )
{
int rem = MethParam%10;
Sum+=rem;
MethParam = MethParam/10;
if(MethParam>10)
compute(MethParam);
return Sum+MethParam;
}
public static void main(String[] args)
{
DigitSum ds = new DigitSum();
System.out.println(ds.compute(435));
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个场景,我想使用特定的路由键将一些消息发布到rabbitmq-exchange,例如.ABC
问题是可能已经存在任何已使用路由密钥"abc"绑定的队列,或者可能没有.这种情况的行为似乎是丢弃该消息,或者如果配置了死信交换,它将被路由到死信交换.
我想动态创建一个与路由密钥同名的队列,即"abc",如果该路由密钥没有队列,而不是丢弃或发送到DLX.
有没有任何已知的方法来做同样的事情?
我在网上搜索了类似的问题,但找不到它.所以,发布在这里.
在以下程序中,为什么'i'的值打印为100?
AFAIK'this'指的是当前的对象; 在这种情况下,它是'TestChild',类名也正确打印.但为什么实例变量的值不是200?
public class TestParentChild {
public static void main(String[] args) {
new TestChild().printName();
}
}
class TestChild extends TestParent{
public int i = 200;
}
class TestParent{
public int i = 100;
public void printName(){
System.err.println(this.getClass().getName());
System.err.println(this.i); //Shouldn't this print 200
}
}
Run Code Online (Sandbox Code Playgroud)
而且以下的输出正如我预期的那样.当我从Parent类调用" this.test() " 时,将调用子类方法.
public class TestParentChild {
public static void main(String[] args) {
new TestChild().printName();
}
}
class TestChild extends TestParent{
public int i = 200;
public void test(){
System.err.println("Child Class : "+i); …Run Code Online (Sandbox Code Playgroud) 我们正在寻找开发缓存机制,并遇到了动态缓存和静态缓存等术语.什么是动态缓存和静态缓存?任何人都可以帮助我理解关于java的例子吗?
我刚开始使用 elasticsearch 5.2 。
如果我有以下映射,我正在尝试获取索引中的所有键:
"properties": {
"name": { "type": "text" },
"article": {
"properties": {
"id": { "type": "text" },
"title": { "type": "text"},
"abstract": { "type": "text"},
"author": {
"properties": {
"id": { "type": "text" },
"name": { "type": "text" }
}}}} } }
Run Code Online (Sandbox Code Playgroud)
是否可以获取所有字段的全名? 像这样:
name,
article.id ,
article.title ,
article.abstract ,
article.author.id,
article.author.name
Run Code Online (Sandbox Code Playgroud)
我怎么能得到呢?
java ×5
mongodb ×2
algorithm ×1
bulkinsert ×1
caching ×1
file-io ×1
inheritance ×1
jms ×1
lucene ×1
mapping ×1
overriding ×1
performance ×1
rabbitmq ×1
this ×1
web ×1