在分布式环境中搜索master-shard实现时,我将面临长搜索时间(10秒的顺序).但是,通过Luke的相同查询以毫秒为单位返回.
该应用程序是一个分布式系统.所有节点共享索引所在的公共NFS装载.为简单起见,我们考虑两个节点Node1和Node2.该/etc/fstab项目如下.
nfs:/vol/indexes /opt/indexes nfs rw,suid,nodev,rsize=32768,wsize=32768,soft,intr,tcp 0 0
Run Code Online (Sandbox Code Playgroud)
有多个Feed(比如说)Feed1和Feed2命中系统,每个节点的每个Feed都有一个分片,每个Feed都有一个分片.索引看起来像
Feed1-master
Feed1-shard-Node1.com
Feed1-shard-Node1.com0
Feed1-shard-Node1.com1
Run Code Online (Sandbox Code Playgroud)
执行搜索的代码是
FeedIndexManager fim = getManager(feedCode);
searcher = fim.getSearcher();
TopDocs docs = searcher.search(q, filter, start + max, sort);
private FeedIndexManager getManager(String feedCode) throws IOException {
if (!_managers.containsKey(feedCode)) {
synchronized(_managers) {
if (!_managers.containsKey(feedCode)) {
File shard = getShardIndexFile(feedCode);
File master = getMasterIndexFile(feedCode);
_managers.put(feedCode, new FeedIndexManager(shard, master));
}
}
}
return _managers.get(feedCode);
}
Run Code Online (Sandbox Code Playgroud)
FeedIndexManager如下.
public class FeedIndexManager implements Closeable { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用ng-repeat和指令显示数组的元素.指令部分对解决方案很重要.但是,数组的元素未绑定并显示空值.
小提琴可以在http://jsfiddle.net/qrdk9sp5/找到
HTML
<div ng-app="app" ng-controller="testCtrl">
{{chat.words}}
<test ng-repeat="word in chat.words"></test>
</div>
Run Code Online (Sandbox Code Playgroud)
JS
var app = angular.module('app', []);
app.controller("testCtrl", function($scope) {
$scope.chat = {
words: [
'Anencephalous', 'Borborygm', 'Collywobbles'
]
};
});
app.directive('test', function() {
return {
restrict: 'EA',
scope: {
word: '='
},
template: "<li>{{word}}</li>",
replace: true,
link: function(scope, elm, attrs) {}
}
});
Run Code Online (Sandbox Code Playgroud)
OUTPUT
["Anencephalous","Borborygm","Collywobbles"]
•
•
•
Run Code Online (Sandbox Code Playgroud)
预期产出
["Anencephalous","Borborygm","Collywobbles"]
•Anencephalous
•Borborygm
•Collywobbles
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助