使用多个字段而不是一个字段在Elasticsearch中升级文档
此外,问题使用自定义ID字段中的Elasticsearch中的UPSERT文档现在,我需要从输入中使用2个以上字段的文档来列出文档。
以与上述问题相同的示例 -
示例数据:
table =“ trade” | tradeid =“ 1234” | qty = 100 | price = 100.00 | buyorsell =“ buy” | stock =“ abcd inc。”
如果我们在上述记录上收到修改:
table =“ trade” | tradeid =“ 1234” | qty = 120 |价格= 101.74 | buyorsell =“ buy” | stock =“ abcd inc。”
我需要根据TradeID和库存来提高。我找不到任何文档提及它。我实际上可以创建一个新的字段,即两个字段的串联,但我想避免它。
Further to question Upsert documents in Elasticsearch using custom ID field, now I need to upsert the documents with 2+ fields from the input.
Taking the same example as the above question -
Sample data:
TABLE="TRADE"|TradeID="1234"|Qty=100|Price=100.00|BuyOrSell="BUY"|Stock="ABCD Inc."
if we receive modification on the above record:
TABLE="TRADE"|TradeID="1234"|Qty=120|Price=101.74|BuyOrSell="BUY"|Stock="ABCD Inc."
I need to upsert based on TradeID and Stock both. I could not find any documentation on-site mentioning it. I could actually create a new field that is the concatenation of two fields but I want to avoid it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
TradeId
和stock
创建一个复合ID,但是,最好使用股票股票代替股票名称。
另一种方法是使用过滤器从
TradeID
和stock
值中创建一个一致的哈希,然后将其用作输出部分中的文档ID:You need to create a compound ID with
TradeID
andStock
, something likeIt would be better to use a stock ticker instead of the stock name, though.
Another way is to use the
fingerprint
filter to create a consistent hash out of theTradeID
andStock
values and then use that hash as the document ID in the output section: