我已经阅读了有关版本控制的 ES博客文章.
但是,我希望能够从更新中获取以前的"_souce"文档.
例如,假设我有这个对象:
{
"name": "John",
"age": 32,
"job": "janitorial technician"
}
// this becomes version 1
Run Code Online (Sandbox Code Playgroud)
我将其更新为:
{
"name": "John",
"age": 32,
"job": "president"
}
// this becomes version 2
Run Code Online (Sandbox Code Playgroud)
然后,通过ES中的版本控制,我能够获得对象的先前"作业"属性吗?我试过这个:
curl -XGET "localhost:9200/index/type/id?version=1"
Run Code Online (Sandbox Code Playgroud)
但这只会返回最新的_source对象(约翰是总统的那个).
我实际上喜欢像StackOverflow那样实现版本差异方面.(顺便说一句,我使用弹性搜索作为我的主要数据库 - 如果有办法与其他nosql数据库一起使用,我很乐意尝试一下.最好是与ES完美结合的.)
好吧,到目前为止我还没弄清楚这一点.希望有人可以提供一些见解.
鉴于以下文档,我如何搜索视频标题中包含"test"的视频的所有文档?我正在使用HTTP API. (基本上,你如何使用弹性搜索搜索嵌套对象?我知道那里必须有文档,但我真的找不到任何文档.)
[{
id:4635,
description:"This is a test description",
author:"John",
author_id:51421,
video: {
title:"This is a test title for a video",
description:"This is my video description",
url:"/url_of_video"
}
},
{
id:4636,
description:"This is a test description 2",
author:"John",
author_id:51421,
video: {
title:"This is an example title for a video",
description:"This is my video description2",
url:"/url_of_video2"
}
},
{
id:4637,
description:"This is a test description3",
author:"John",
author_id:51421,
video: {
title:"This is a test title for a video3",
description:"This is …Run Code Online (Sandbox Code Playgroud) 我在express.js中使用了handlebars.js hbs包装器.我有模板工作正常,但我需要添加部分以使用我的视图呈现.
我想做这样的事情:
hbs.registerPartial('headPartial', 'header');
// where "header" is an .hbs file in my views folder
Run Code Online (Sandbox Code Playgroud)
但是,它正在抛出"标题部分无法找到".
如果我将一个html字符串传递给第二个参数,我可以使registerPartial工作,但我想为我的部分使用单独的视图文件.
我没有找到任何关于此的文档,但希望我可能只是遗漏了一些简单的东西.
有谁知道如何在registerPartial方法中使用视图文件?如果是这样,我该如何实现呢?
UPDATE
为了提供更多上下文,让我添加更多代码.这是我的"服务器"文件 - app.js
var express = require('express')
, routes = require('./routes')
, hbs = require('hbs');
var app = module.exports = express.createServer();
// Configuration
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'hbs');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
// this is the line …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的查询:
{
"query": {
"constant_score":
"filter": {
"missing": {
"field": "parent_id"
}
}
}
},
"size": limit,
"from": offset
}
Run Code Online (Sandbox Code Playgroud)
我的类型有一个parent_id和一个wall_id字段.如何修改此查询以便我可以获得所有没有a parent_id且没有a的类型wall_id?我似乎无法从文档中解读它.感谢您提供的任何帮助!
UPDATE
我有以下查询可行,但我不喜欢query标题上的catchall .有没有办法做到这一点,而不必添加"catchall?
{
"query":{
"filtered":{
"query":{
"field":{ "title":"*" }
},
"filter":{
"and":{
"filters":[
{
"missing":{ "field":"parent_id" }
},
{
"missing":{ "field":"wall_id" }
}
]
}
}
}
}, "size":10, "from":0
}
Run Code Online (Sandbox Code Playgroud) 我决定使用ElasticSearch作为我搜索网站主要数据的主要商店.它是一个NoSQL数据库,提供全文搜索和其他令人敬畏的搜索功能.
将我的用户数据和社交关系存储在ElasticSearch引擎中也是有用的吗?或者我应该将其存储在单独的数据库中?
短篇故事:
我需要> 3.7.3版本的sqlite3,但我目前有3.5.?. 我该如何升级包裹?
很长的故事:
尝试安装etherpad-lite(etherpad的node.js实现).由于sqlite3包安装失败.我试图安装sqlite3的npm包...再次失败.根据这个github问题(https://github.com/developmentseed/node-sqlite3/issues/27),看起来好像我需要大于3.7.3的软件包.我似乎无法找到有关如何升级包的任何文档.
感谢您提供的任何帮助!
我有一个three.js场景,想知道视口的3D边界.
例如,假设我有一个宽500像素,高1000像素的画布.我的相机正在看着位置{ 0, 0, 0 }并处于适当位置{ 0, 0, 100 };
我的相机永远不动.
假设我有一个物体位于{ 0, 0, 0 }.我需要能够将该对象移动到可视区域内的各个点(在摄像机视野内).我怎样才能计算出摄像机视野的上/左角?另外,我怎么能从左边计算20%,从摄像机视野顶部算出10%?
这是我的相机对象:
{
"object": {
"uuid": "E26C5F88-CD17-45F8-A492-F3DD704949BF",
"type": "PerspectiveCamera",
"matrix": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 100, 1],
"zoom": 1,
"fov": 50,
"aspect": 0.625,
"near": 0.1,
"far": 1000
}
}
Run Code Online (Sandbox Code Playgroud) 我似乎无法理解弹性搜索中的facets的QueryDSL.下面是我的查询对象,以及我的tags数组的映射.我试图让这些基于标签进行分面导航.每个"元素"将在标签数组中关联多个标签[并非所有元素都有标签.有些人会有一个空数组.每个标记都是具有id和tag属性的对象.
我已经尝试了嵌套的facet方法并得到"标签没有嵌套"的错误,所以我在下面尝试这个.我没有收到错误,但返回JSON中没有facets对象.我一直在使用此页面寻求帮助:http://www.elasticsearch.org/guide/reference/api/search/facets/index.html.
任何人都可以帮我正确格式化并了解这些的组织吗?我感谢任何帮助!
// this is my query object
{
"sort":{ "created_at":{ "order":"desc" } },
"query":{
"constant_score":{
"filter":{
"and":[
{ "missing":{ "field":"parent_id" } },
{ "missing":{ "field":"wall_id" } },
{ "term":{ "active":true } }
]
}
}
},
"facets":{
"tags":{ "terms":{ "field":"tags.tag" } }
}
}
// this is the mapping for the tags array
"tags":{
"type":"nested",
"include_in_parent":true,
"properties":{
"id":{ "type":"integer" },
"tag":{ "type":"string" }
}
},
Run Code Online (Sandbox Code Playgroud)