简体   繁体   English

如何在Elasticsearch上更改别名值?

[英]How to change the alias value on Elasticsearch?

I am new to Elasticsearch and I want to know if we have a way to change the value of the alias index ? 我是Elasticsearch的新手,我想知道我们是否可以更改别名索引的值? I will give you examples; 我会给你例子;

For example we have a index that holds the credit card numbers; 例如,我们有一个包含信用卡号的索引;

4444-444-777 .... and so on, 4444-444-777 ....等等,

Then I have a alias to that index, lets say alias1, 然后我对该索引有一个别名,可以说alias1,

What I want to do is, once I call alias1, the user will automatically see; 我想做的是,一旦我调用alias1,用户将自动看到。

xxxx-xxx-777 instead of 4444-444-777. xxxx-xxx-777,而不是4444-444-777。

Can you please give me some ideas how to do it ? 你能给我一些想法怎么做吗?

I'm afraid this is not possible with aliases. 恐怕别名是不可能的。 Aliases have functionality to filter the query, but this is just an inclusion / exclusion filter. 别名具有过滤查询的功能 ,但这只是一个包含/排除过滤器。 For example, alias1 could be a filtered alias that only allows the search query to see user1 documents. 例如, alias1可以是已过滤的别名,仅允许搜索查询查看user1文档。

Aliases do not have any capability to actually modify or manipulate data. 别名不具有实际修改或处理数据的任何功能。

There are some options, but they all have trade-offs. 有一些选择,但是它们都有一些折衷。

Script Fields 脚本字段

You can use Script Fields to provide a "virtual" field. 您可以使用脚本字段来提供“虚拟”字段。 Essentially, you run a script which loads some field, then performs whatever manipulation you need (eg 4444-444-777 -> xxxx-xxx-777 ). 本质上,您运行的脚本会加载某些字段,然后执行所需的任何操作(例如4444-444-777 > xxxx-xxx-777 )。 This is then returned to you as an extra field in the search results. 然后将其作为搜索结果中的额外字段返回给您。 The caveat is that the original data is still visible in the original _source , so your app will need to make sure that isn't exposed. 需要注意的是,原始数据仍在原始_source仍然可见,因此您的应用将需要确保未公开该数据。

Transform 转变

If you don't ever want the original data to be returned, you can perform a Transform which will physically alter the _source document before it is indexed. 如果您不希望返回原始数据,则可以执行Transform ,它将在对_source文档建立索引之前对其进行物理更改。 This means that the data you get back from the search results will be pre-manipulated...but you will never be able to access the original data (because it has been transformed). 这意味着您将从搜索结果中获取的数据将被预先处理...但是您将永远无法访问原始数据(因为它已经被转换)。

Your application code 您的申请代码

It may be best to just perform this filtering in your application code. 最好只在应用程序代码中执行此过滤。 Simpler, easier to change, not doing anything fundamentally different from what ES would have to do anyway. 更简单,更容易更改,并且根本没有做任何与ES要做的根本不同的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 ElasticSearch 中更改别名返回 200 并确认但不更改别名 - Changing alias in ElasticSearch returns 200 and acknowledged but does not change alias Elasticsearch和Spring Data:如何使用别名重新索引 - Elasticsearch and Spring Data: how to reindex with alias 如何在Elasticsearch java api中找到Alias索引? - How to find Index by Alias in Elasticsearch java api? 如何在Elasticsearch 6.1.1 Java API中按别名查找索引 - How to find indexes by alias name in elasticsearch 6.1.1 java api 在Java Xstream中如何更改对象内部的别名? - in Java Xstream how to change alias inside an object? 如何更改密钥库中密钥的别名? - How to change the alias of a key within a keystore? 如何在elasticsearch中匹配精确值? - How to match exact value in elasticsearch? 如何在 elasticsearch 中创建两个别名,一个在热层上,一个在总(或暖、冷)层上? - How to create two alias in elasticsearch, one on hot tier and one on total(or warm, cold) tier? 如何将 elasticsearch 查询更改为 Java API? - How to change the elasticsearch query to Java API? 如何更改Java Keystore(JKS)密钥库和别名密码以使它们正常工作 - How to change Java Keystore(JKS) keystore and alias password so that they work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM