我将在rails项目中使用弹性搜索我的ruby.当我搜索一些在我的文章中使用过多的单词时,我收到此错误.
NoMethodError (undefined method `highlight' for #<Elasticsearch::Model::Response::Result:0x007f062ed26708>)
Run Code Online (Sandbox Code Playgroud)
我在日志制作中得到了这个.这就是我所做的一切:在控制器中:
# POST /search/article
def search
render json: Article.search(params[:query]), each_serializer: ElasticsearchResultsSerializer
end
Run Code Online (Sandbox Code Playgroud)
这是我的article.rb模型
#default_scope { order('created_at DESC') }
scope :visible, -> { where(enabled: true) }
after_commit on: [:create] do
self.keywords = self.keywords.each {|str| str.force_encoding("UTF-8")}
__elasticsearch__.index_document if self.enabled?
end
after_commit on: [:update] do
self.keywords = self.keywords.each {|str| str.force_encoding("UTF-8")}
__elasticsearch__.update_document if self.enabled?
end
after_commit on: [:destroy] do
__elasticsearch__.delete_document
end
settings index: { number_of_shards: 1, number_of_replicas: 0 }
mappings dynamic: 'false' do
indexes :content, type: "string", …Run Code Online (Sandbox Code Playgroud) 我有一个用例来验证OAuth1请求,该请求使用RSA私钥进行签名,并在服务器端使用RSA公钥进行验证.
我从Twitter找到了这个库,它可以帮助我们验证/验证Oauth签名的请求. https://github.com/twitter/joauth
我想利用这个库来验证来自Jersey或Spring MVC操作方法的请求.来自客户端的请求将使用私钥进行签名.在我结束时,我将使用客户端的公钥来验证请求.这意味着RSA-SHA1算法.
Twitter joauth似乎很有用,但我错过了将HttpServletRequest转换为OAuthRequest的代码
库自述文件建议将其作为工具,但我找不到代码javax.servlet.http.HttpServletRequest - > com.twitter.joauth.OAuthRequest转换.
请求验证发生在具有以下签名的验证方法中.
public VerifierResult verify(UnpackedRequest.OAuth1Request request, String tokenSecret, String consumerSecret);
Run Code Online (Sandbox Code Playgroud)
其次,我还想知道当verify方法接受String参数时,哪种方法最适合使用/读取具有twitter joauth的RSA公钥?
我正在使用spring-data-elasticsearch,一开始一切正常.
@Document( type = "products", indexName = "empty" )
public class Product
{
...
}
public interface ProductRepository extends ElasticsearchRepository<Product, String>
{
...
}
Run Code Online (Sandbox Code Playgroud)
在我的模型中,我可以搜索产品.
@Autowired
private ProductRepository repository;
...
repository.findByIdentifier( "xxx" ).getCategory() );
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是 - 我在不同的索引中使用相同的Elasticsearch类型,我想对所有查询使用相同的文档.我可以通过池处理更多连接 - 但我不知道如何实现这一点.
我希望有这样的东西:
ProductRepository customerRepo = ElasticsearchPool.getRepoByCustomer("abc", ProductRepository.class);
repository.findByIdentifier( "xxx" ).getCategory();
Run Code Online (Sandbox Code Playgroud)
是否可以在运行时使用不同的索引创建存储库?
非常感谢Marcel
java elasticsearch spring-data spring-boot spring-data-elasticsearch
我正在使用谷歌图表创建一个多级甜甜圈图表.我成功创建了单级图表.但现在我必须在该图表中创建另一个图表.请帮我.还有可能以圆形形式在图表切片上写文字吗?
这是我的单个甜甜圈聊天的代码.
HTML
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<div id="donutchart" style="width: 900px; height: 500px;"></div>
Run Code Online (Sandbox Code Playgroud)
JS
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'My Daily Activities',
pieHole: 0.4,
chartArea:{left: '100'},
pieSliceText: 'label',
pieStartAngle: 0,
pieSliceTextStyle:{color: 'white', fontName: 'arial', fontSize: 10}
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
Run Code Online (Sandbox Code Playgroud)
这里是JsFiddle的代码链接
IT应该是这样的

javascript charts html5 google-chartwrapper google-pie-chart
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html提到可以通过以下方式禁用自动创建索引:
通过在所有节点的配置文件中将action.auto_create_index设置为false,可以禁用自动索引创建.
如何在Elasticsearch中使用Java AWSElasticsearchClient类或以任何其他方式将其作为服务来完成?
看起来像一个简单的用例但由于某种原因我只是无法弄清楚如何做到这一点,或谷歌一个明确的例子.
假设我在logstash消息中存储了一条消息:
"info:2015-11-28 22:02:19,232:common:INFO:ENV:Production用户:无:用户名:无:LOG:发布到公交车"
我想在kibana(版本4)中搜索短语:"发布到公共汽车"我会得到一组结果但如果我要搜索:"无:日志:发布到公共汽车"然后我得到"否结果发现".
虽然显然这个短语确实存在并且由之前的搜索返回.
所以我的问题基本上是 - 发生了什么?搜索可能的长短语的正确方法是什么?为什么第二个示例失败.
编辑: 存储的JSON.
{
"_index": "logz-ngdxrkmolklnvngumaitximbohqwbocg-151206_v1",
"_type": "django_logger",
"_id": "AVF2DPxZZst_8_8_m-se",
"_score": null,
"_source": {
"log": " publishing to bus {'user_id': 8866, 'event_id': 'aibRBPcLxcAzsEVRtFZVU5', 'timestamp': 1449384441, 'quotes': {}, 'rates': {u'EURUSD': Decimal('1.061025'), u'GBPUSD': Decimal('1.494125'), u'EURGBP': Decimal('0.710150')}, 'event': 'AccountInstrumentsUpdated', 'minute': 1449384420}",
"logger": "common",
"log_level": "INFO",
"message": "2015-12-06 06:47:21,298:common:INFO:ENV: Production User:None:Username:None:LOG: publishing to bus {'user_id': 8866, 'event_id': 'aibRBPcLxcAzsEVRtFZVU5', 'timestamp': 1449384441, 'quotes': {}, 'rates': {u'EURUSD': Decimal('1.061025'), u'GBPUSD': Decimal('1.494125'), u'EURGBP': Decimal('0.710150')}, 'event': 'AccountInstrumentsUpdated', 'minute': 1449384420}",
"type": "django_logger",
"tags": …Run Code Online (Sandbox Code Playgroud) " 关键字 "字段类型与在Elasticsearch 中使用" not_analyzed "作为分析器的字段之间是否有任何区别?如果有一个,何时使用哪个?
所以,我们假设我的日志行的一部分看起来像这样:
GET /restAPI/callMethod1/8675309
Run Code Online (Sandbox Code Playgroud)
GET匹配一个http方法,得到提取,余数匹配一个URI,并且也被提取.现在在logstash配置中让我们假设我想做这样的事情......
if [METHOD] == "GET" {
if [URI] (CONTAINS <--Is there a way to do this?) =="restAPI/callMethod1"{
....
Run Code Online (Sandbox Code Playgroud)
有办法做到这一点吗?如果是这样,我该怎么做呢?
谢谢
我有2个索引movie_indexer和trial_indexer.
我使用以下命令删除movie_indexer:
curl -XDELETE "http://localhost:9200/movie_indexer/"
Run Code Online (Sandbox Code Playgroud)
然后我重申了Kibana.它仍显示索引及其值.
我用的时候
curl -XDELETE "http://localhost:9200/.kibana"
Run Code Online (Sandbox Code Playgroud)
之后trial_indexer就失踪了.
注意:使用后一个命令后,我可以创建索引模式,trial_indexer但不能为movie_indexer 创建索引模式.
我想删除特定的索引,而不需要为未删除的索引重新创建索引模式.我怎样才能做到这一点?(我正在使用Windows)
在将Rails更新到4.2.5.1并更新用户文档后,我不时会收到此异常
Elasticsearch :: Transport :: Transport :: Errors :: Conflict:[409] {"error":"VersionConflictEngineException [[users] [0] [user] [1]:版本冲突,当前[7],提供[6] ]", "状态":409}
但是,我没有在更新请求中传递任何显式版本.我想两个不同的进程正在尝试同时更新同一个文档,但除了Rails版本之外它没有任何改变.
我正在使用elasticsearch-model(0.1.8)elasticsearch-rails(0.1.8)elasticsearch(1.0.15)elasticsearch-api(1.0.15)和elasticsearch-transport(1.0.15)
elasticsearch版本是Version:1.2.2,Build:9902f08/2014-07-09T12:02:32Z,JVM:1.7.0_65
ruby-on-rails elasticsearch elasticsearch-model elasticsearch-rails
logstash ×3
java ×2
kibana ×2
charts ×1
cryptography ×1
html5 ×1
javascript ×1
joauth ×1
kibana-4 ×1
oauth ×1
rsa ×1
ruby ×1
spring-boot ×1
spring-data ×1