Home  >  Article  >  Backend Development  >  Reverse mapping in Aerospike

Reverse mapping in Aerospike

王林
王林forward
2024-02-08 22:12:221192browse

Aerospike 中的反向映射

Reverse mapping in Aerospike is an important feature that allows developers to query and retrieve data from the data store. Reverse mapping maps the values ​​of key-value pairs back to the corresponding keys by creating an index in the database. This capability helps developers query and analyze data more efficiently, improving application performance. In this article, we will detail the principles and usage of reverse mapping in Aerospike and how to use it in PHP. Whether you are a beginner or an experienced developer, this article will provide you with a comprehensive guide to reverse mapping to help you take advantage of the power of the Aerospike database.

Question content

I have some records in aerospike in the following key-value pairs:

Key : "1234" 
Value : {
            "XYZ":{
                "B":[1,3]
                "C":[3,4]
            }
        }

Key : "5678" 
Value : {
            "XYZ":{
                "B":[1,3,5]
                "C":[3,4]
            }
        }

I want to get all keys from the set where field "b" contains 3 in json value. Is there a way to query all such keys in golang?

Workaround

Yes, you can build a secondary index on the values ​​in map key "B" at that nesting level...and then run a secondary index query to get all Matching records.

You can perform the same operation in Go using the equivalent API.

Many Java interactive code examples are located at: https://developer.aerospike.com/tutorials/java/cdt_indexing

For example, here is the top-level example with a string value:

Then another example where SI can be built on nested sublevels:

The above is the detailed content of Reverse mapping in Aerospike. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete