Address Information Acquisition Method, Device, Electronic Device, Storage Medium and Product

By caching different levels of data of address information, the number of database interactions is reduced and the efficiency of address information is improved.

CN114297523BActive Publication Date: 2025-05-30SOUNDAI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111546369.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-16
Publication Date
2025-05-30
Estimated Expiration
2041-12-16

AI Technical Summary

Technical Problem

In the prior art, when acquiring address information, the server needs to interact with the database multiple times, resulting in low acquisition efficiency.

Method used

By obtaining the first level of the first address information, the second address information of the second level different from it is determined and cached to the local area, so as to directly obtain from the local area during subsequent acquisitions, reducing interaction with the database.

Benefits of technology

It improves the efficiency of obtaining address information, reduces response time, and saves time for database interaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114297523B_ABST
    Figure CN114297523B_ABST
Patent Text Reader

Abstract

The present application discloses a method, apparatus, electronic device, storage medium and product for obtaining address information, belonging to the field of Internet technology. An embodiment of the present application provides a method for obtaining address information, which includes obtaining a first query condition for querying first address information, determining at least one second query condition based on the first level of the first address information, obtaining the corresponding first address information and each second address information from a database based on the first query condition and each second query condition, outputting the first address information, and caching each second address information locally; in response to a first acquisition request, obtaining the second address information from local. When obtaining the first address information, this method also obtains the second address information of a second level different from the first level, so that when obtaining the second address information, it can be directly obtained from local without interacting with the database again, saving time and thus improving the acquisition efficiency of address information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet technologies, and in particular, to a method, apparatus, electronic device, storage medium, and product for obtaining address information. Background Art

[0002] Currently, in many scenarios, it is necessary to obtain the address information of users. For example, when users sign up for an exam or get vaccinated online, in these scenarios, it is necessary to obtain address information such as the province, city, district, county, town, and street where the user is located. And this address information is generally stored in a database. Therefore, when obtaining the address information of a user, the database needs to be queried.

[0003] In related technologies, when obtaining the target province information, the server sends a fetch request to the database, and the database returns the province information of multiple provinces to the server. Then the server determines the target province information from the multiple province information. When obtaining the target city information, the server sends a fetch request to the database again, and the database returns the city information of multiple cities under the target province information to the server. Then the server determines the target city information from the multiple city information. And so on, to obtain the address information such as the province, city, district, county, town, and street where the user is located level by level.

[0004] However, in the process of obtaining address information by the method in related technologies, the server needs to interact with the database multiple times, and each interaction requires a certain amount of time. Therefore, this method results in low efficiency in obtaining address information. Summary of the Invention

[0005] Embodiments of this application provide a method, apparatus, electronic device, storage medium, and product for obtaining address information, which can improve the efficiency of obtaining address information. The technical solutions are as follows:

[0006] On the one hand, a method for obtaining address information is provided. The method includes:

[0007] Obtain a first query condition, where the first query condition is used to query first address information;

[0008] Based on the first level of the first address information, determine at least one second query condition, where each second query condition is used to query second address information of one level, and the second level of the second address information is different from the first level of the first address information;

[0009] Based on the first query condition and each second query condition, obtain the corresponding first address information and each second address information from the database;

[0010] Output the first address information, and cache each second address information locally;

[0011] In response to a first acquisition request for acquiring second address information, acquire the second address information corresponding to the first acquisition request from the local.

[0012] In a possible implementation manner, determining at least one second query condition based on a first level of the first address information includes:

[0013] Determine a first level of the first address information;

[0014] Based on the first level, determine levels lower than the first level to obtain at least one second level;

[0015] Based on the at least one second level, determine the at least one second query condition.

[0016] In another possible implementation manner, determining the first level of the first address information includes:

[0017] If the first address information for which the first query condition is used for querying is address information included in a province, autonomous region, or municipality directly under the Central Government, determine that the first level of the first address information is the prefecture-level administrative level, and the prefecture-level administrative level includes prefecture-level cities and autonomous prefectures;

[0018] If the first address information for which the first query condition is used for querying is address information included in a prefecture-level city or autonomous prefecture, determine that the first level of the first address information is the county-level administrative level, and the county-level administrative level includes districts, county-level cities, and counties;

[0019] If the first address information for which the first query condition is used for querying is address information included in a district, county-level city, or county, determine that the first level of the first address information is the township-level administrative level, and the township-level administrative level includes townships, towns, and sub-districts;

[0020] If the first address information for which the first query condition is used for querying is address information included in a township, town, or sub-district, determine that the first level of the first address information is the village-level administrative level, and the village-level administrative level includes communities and villages.

[0021] In another possible implementation manner, acquiring the corresponding first address information and each second address information from the database based on the first query condition and each second query condition includes:

[0022] If the first level is a prefecture-level administrative level, obtain the address information corresponding to the prefecture-level administrative level and the second address information corresponding to the county-level administrative level from the database, and obtain the first address information from the address information corresponding to the prefecture-level administrative level; or, obtain the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, and the second address information corresponding to the township-level administrative level from the database, and obtain the first address information from the address information corresponding to the prefecture-level administrative level; or, obtain the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level from the database, and obtain the first address information from the address information corresponding to the prefecture-level administrative level, where the village-level administrative level includes communities and villages;

[0023] If the first level is a county-level administrative level, obtain the address information corresponding to the county-level administrative level and the second address information corresponding to the township-level administrative level from the database, and obtain the first address information from the address information corresponding to the county-level administrative level; or, obtain the address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level from the database, and obtain the first address information from the address information corresponding to the county-level administrative level;

[0024] If the first level is a township-level administrative level, obtain the address information corresponding to the township-level administrative level and the second address information corresponding to the village-level administrative level from the database, and obtain the first address information from the address information corresponding to the township-level administrative level.

[0025] In another possible implementation, obtaining the corresponding first address information and each second address information from the database based on the first query condition and each second query condition includes:

[0026] Send a second acquisition request to the database, where the second acquisition request carries the first query condition and each second query condition, and the database is used to obtain the corresponding first address information and each second address information based on the first query condition and each second query condition;

[0027] Receive the first address information and each second address information sent by the database.

[0028] In another possible implementation, in response to a first acquisition request for obtaining second address information, obtaining the second address information corresponding to the first acquisition request from the local includes:

[0029] In response to the first acquisition request, determine a first logical query statement for acquiring the second address information;

[0030] Based on the first logical query statement, determine the second address information from multiple hierarchical matching trees locally, where the hierarchical level of the address information represented by the parent node in the hierarchical matching tree is higher than that of the address information represented by the child node.

[0031] In another possible implementation, the determining the second address information from multiple hierarchical matching trees locally based on the first logical query statement includes:

[0032] Determine the address information with the highest hierarchical level and the address information with the lowest hierarchical level in the first logical query statement;

[0033] Based on the address information with the highest hierarchical level, determine, from multiple hierarchical matching trees locally, the hierarchical matching tree with the top node being the address information with the highest hierarchical level as the target hierarchical matching tree;

[0034] Based on the address information with the lowest hierarchical level, determine, from the target hierarchical matching tree, the address information corresponding to the node with the address information with the lowest hierarchical level as the parent node as the second address information.

[0035] In another possible implementation, the process of determining the hierarchical matching tree includes:

[0036] Determine the address information that belongs to the same province, autonomous region, or municipality directly under the Central Government among the address information obtained from the database to obtain address information with an associated relationship;

[0037] Determine the address information that belongs to the same prefecture-level city or autonomous prefecture among the address information obtained from the database to obtain address information with an associated relationship;

[0038] Determine the address information that belongs to the same district, county-level city, or county among the address information obtained from the database to obtain address information with an associated relationship;

[0039] Determine the address information that belongs to the same township, town, or street among the address information obtained from the database to obtain address information with an associated relationship;

[0040] Determine the address information that belongs to the same community or village among the address information obtained from the database to obtain address information with an associated relationship;

[0041] Based on the address information with the associated relationship and the hierarchical level of each address information, connect two nodes to obtain a hierarchical matching tree.

[0042] In another possible implementation, the method further includes:

[0043] In response to receiving a notification message sent by the database, obtain the changed address information in the database from the notification message, where the notification message is sent when the address information in the database changes;

[0044] Update the address information cached locally based on the changed address information in the database.

[0045] On the other hand, an address information acquisition device is provided, and the device includes:

[0046] A first acquisition module, configured to acquire a first query condition for querying first address information;

[0047] A first determination module, configured to determine at least one second query condition based on the first level of the first address information, where each second query condition is used to query second address information of one level, and the second level of the second address information is different from the first level of the first address information;

[0048] A second acquisition module, configured to acquire the corresponding first address information and each second address information from the database based on the first query condition and each second query condition;

[0049] A cache module, configured to output the first address information and cache each second address information locally;

[0050] A third acquisition module, configured to, in response to a first acquisition request for acquiring second address information, acquire the second address information corresponding to the first acquisition request from the local.

[0051] In a possible implementation manner, the first determination module is configured to determine the first level of the first address information; based on the first level, determine levels lower than the first level to obtain at least one second level; and based on the at least one second level, determine the at least one second query condition.

[0052] In another possible implementation, the first determination module is configured to, if the first address information queried by the first query condition is the address information included in a province, autonomous region or municipality directly under the Central Government, determine that the first level of the first address information is the prefecture-level administrative level, and the prefecture-level administrative level includes prefecture-level cities and autonomous prefectures; if the first address information queried by the first query condition is the address information included in a prefecture-level city or autonomous prefecture, determine that the first level of the first address information is the county-level administrative level, and the county-level administrative level includes districts, county-level cities and counties; if the first address information queried by the first query condition is the address information included in a district, county-level city or county, determine that the first level of the first address information is the township-level administrative level, and the township-level administrative level includes townships, towns and sub-districts; if the first address information queried by the first query condition is the address information included in a township, town or sub-district, determine that the first level of the first address information is the village-level administrative level, and the village-level administrative level includes communities and villages.

[0053] In another possible implementation, the second acquisition module is configured to, if the first level is the prefecture-level administrative level, acquire from the database the address information corresponding to the prefecture-level administrative level and the second address information corresponding to the county-level administrative level, and acquire the first address information from the address information corresponding to the prefecture-level administrative level; or, acquire from the database the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, and the second address information corresponding to the township-level administrative level, and acquire the first address information from the address information corresponding to the prefecture-level administrative level; or, acquire from the database the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level, and acquire the first address information from the address information corresponding to the prefecture-level administrative level, where the village-level administrative level includes communities and villages; if the first level is the county-level administrative level, acquire from the database the address information corresponding to the county-level administrative level and the second address information corresponding to the township-level administrative level, and acquire the first address information from the address information corresponding to the county-level administrative level; or, acquire from the database the address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level, and acquire the first address information from the address information corresponding to the county-level administrative level; if the first level is the township-level administrative level, acquire from the database the address information corresponding to the township-level administrative level and the second address information corresponding to the village-level administrative level, and acquire the first address information from the address information corresponding to the township-level administrative level.

[0054] In another possible implementation, the second acquisition module is configured to send a second acquisition request to the database, where the second acquisition request carries the first query condition and each second query condition, and the database is configured to acquire the corresponding first address information and each second address information based on the first query condition and each second query condition; and receive the first address information and each second address information sent by the database.

[0055] In another possible implementation, the third acquisition module is configured to, in response to the first acquisition request, determine a first logical query statement for acquiring the second address information; and based on the first logical query statement, determine the second address information from multiple hierarchical matching trees in the local area, where the hierarchical level of the address information represented by the parent node in the hierarchical matching tree is higher than that of the address information represented by the child node.

[0056] In another possible implementation, the third acquisition module is configured to determine the address information with the highest hierarchical level and the address information with the lowest hierarchical level in the first logical query statement; based on the address information with the highest hierarchical level, determine, from multiple hierarchical matching trees in the local area, the hierarchical matching tree with the top node being the address information with the highest hierarchical level as the target hierarchical matching tree; and based on the address information with the lowest hierarchical level, determine, from the target hierarchical matching tree, the address information corresponding to the node with the address information with the lowest hierarchical level as the parent node as the second address information.

[0057] In another possible implementation, the apparatus further includes:

[0058] A second determination module, configured to determine the address information belonging to the same province, autonomous region, or municipality directly under the Central Government among the address information acquired from the database, to obtain the address information with an associated relationship; determine the address information belonging to the same prefecture-level city or autonomous prefecture among the address information acquired from the database, to obtain the address information with an associated relationship; determine the address information belonging to the same district, county-level city, and county among the address information acquired from the database, to obtain the address information with an associated relationship; determine the address information belonging to the same township, town, or street among the address information acquired from the database, to obtain the address information with an associated relationship; determine the address information belonging to the same community or village among the address information acquired from the database, to obtain the address information with an associated relationship;

[0059] A third determination module, configured to connect two nodes based on the address information with the associated relationship and the hierarchical level of each address information, to obtain a hierarchical matching tree.

[0060] In another possible implementation, the apparatus further includes:

[0061] A fourth acquisition module, configured to, in response to receiving a notification message sent by the database, acquire, from the notification message, address information that has changed in the database, where the notification message is sent when the address information in the database changes;

[0062] An update module, configured to update the address information cached locally based on the address information that has changed in the database.

[0063] On the other hand, an electronic device is provided, where the electronic device includes a processor and a memory, and at least one program code is stored in the memory. The at least one program code is loaded and executed by the processor to implement the address information acquisition method according to any one of the above possible implementation manners.

[0064] On the other hand, a computer-readable storage medium is provided, where at least one program code is stored in the computer-readable storage medium. The at least one program code is loaded and executed by a processor to implement the address information acquisition method according to any one of the above possible implementation manners.

[0065] On the other hand, a computer program product is provided, where the computer program product includes computer program code. The computer program code is stored in a computer-readable storage medium, and a processor of an electronic device reads the computer program code from the computer-readable storage medium. The processor executes the computer program code, so that the electronic device executes the address information acquisition method according to any one of the above possible implementation manners.

[0066] The beneficial effects brought by the technical solution provided in the embodiments of the present application are:

[0067] The embodiments of the present application provide an address information acquisition method. When acquiring first address information, the method also acquires second address information of a second level different from the first level according to the first level of the first address information, and caches the second address information locally. In this way, when acquiring the second address information, it can be directly obtained locally without interacting with the database again, saving time and thus improving the acquisition efficiency of the address information.

[0068] It should be understood that the above general description and the following detailed description are only exemplary and do not limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] Figure 1 is a schematic diagram of an implementation environment of an address information acquisition method provided in an embodiment of the present application;

[0070] Figure 2 is a flowchart of an address information acquisition method provided in an embodiment of the present application;

[0071] Figure 3 It is a flowchart of a method for obtaining address information provided by an embodiment of the present application;

[0072] Figure 4 It is a flowchart of a method for obtaining address information provided by an embodiment of the present application;

[0073] Figure 5 It is a schematic structural diagram of a device for obtaining address information provided by an embodiment of the present application;

[0074] Figure 6 It is a structural block diagram of a terminal provided by an embodiment of the present application;

[0075] Figure 7 It is a structural block diagram of a server provided by an embodiment of the present application. Specific embodiments

[0076] To make the technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below.

[0077] It can be understood that the terms "first", "second", etc. used in the present application may be used in this article to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. The terms "at least one", "multiple", "each", "any one" used in the present application, at least one includes one, two or more than two, multiple includes two or more than two, and each refers to each of the corresponding multiple, and any one refers to any one of the multiple.

[0078] Figure 1 It is a schematic diagram of an implementation environment of a method for obtaining address information provided by an embodiment of the present application. The implementation environment includes: an electronic device and a database, and the electronic device and the database can be connected through a wireless or wired network.

[0079] In the embodiments of the present application, the electronic device can be provided as a terminal, or a server, or a terminal and a server. If the electronic device is provided as a terminal, the terminal obtains address information from the database; if the electronic device is provided as a server, the server obtains address information from the database; if the electronic device is provided as a terminal and a server, the server first obtains address information from the database, and then the server returns the obtained address information to the terminal, and the terminal displays the address information on the interface. In the embodiments of the present application, only the case where the electronic device is provided as a terminal and a server is taken as an example for illustration.

[0080] Correspondingly, as Figure 1As shown in the figure, the implementation environment includes: a terminal 101, a server 102, and a database 103. The terminal 101 and the server 102 can be connected through a wireless or wired network, and the server 102 and the database 103 can be connected through a wireless or wired network. A target application is installed on the terminal 101, and the server 102 is the server for the target application. When the target application needs to obtain address information during operation, the terminal 101 sends a retrieval request to the server 102. Based on the retrieval request, the server 102 retrieves the address information from the database 103 and then returns it to the terminal 101.

[0081] The method provided by the embodiments of the present application can be applied to any scenario that requires obtaining address information. For example, the method is applied to the scenario of getting vaccinated. In this scenario, before getting vaccinated, it is necessary to obtain address information such as the province, city, district, and county where the user is located. Another example is that the method is applied to the scenario of online shopping. In this scenario, it is necessary to obtain address information such as the province, city, district, and county where the user is located as the delivery address of the user. Another example is that the method is applied to the scenario where a user signs up for an exam online. In this scenario, it is necessary to obtain address information such as the province, city, district, and county where the user is located during the registration process. In the embodiments of the present application, the application scenarios of the method are not specifically limited.

[0082] The terminal 101 is at least one of devices such as a mobile phone, a tablet computer, and a PC (Personal Computer) device. The server 102 can be at least one of a single server, a server cluster composed of multiple servers, a cloud server, a cloud computing platform, and a virtualization center. The database 103 can be at least one of a single server, a server cluster composed of multiple servers, a cloud server, a cloud computing platform, and a virtualization center.

[0083] Figure 2 is a flowchart of a method for obtaining address information provided by the embodiments of the present application. As Figure 2 shown, the method includes:

[0084] Step 201: Obtain a first query condition, where the first query condition is used to query first address information.

[0085] Step 202: Based on the first level of the first address information, determine at least one second query condition, where each second query condition is used to query second address information of one level, and the second level of the second address information is different from the first level of the first address information.

[0086] Step 203: Based on the first query condition and each second query condition, obtain the corresponding first address information and each second address information from the database.

[0087] Step 204: Output the first address information and cache each second address information locally.

[0088] Step 205: In response to a first acquisition request for acquiring the second address information, acquire the second address information corresponding to the first acquisition request from the local.

[0089] In a possible implementation manner, based on the first level of the first address information, determine at least one second query condition, including:

[0090] Determine the first level of the first address information;

[0091] Based on the first level, determine the levels lower than the first level to obtain at least one second level;

[0092] Based on at least one second level, determine at least one second query condition.

[0093] In another possible implementation manner, determining the first level of the first address information includes:

[0094] If the first address information queried by the first query condition is the address information included in a province, autonomous region or municipality directly under the Central Government, determine that the first level of the first address information is the prefecture-level administrative level, and the prefecture-level administrative level includes prefecture-level cities and autonomous prefectures;

[0095] If the first address information queried by the first query condition is the address information included in a prefecture-level city or autonomous prefecture, determine that the first level of the first address information is the county-level administrative level, and the county-level administrative level includes districts, county-level cities and counties;

[0096] If the first address information queried by the first query condition is the address information included in a district, county-level city or county, determine that the first level of the first address information is the township-level administrative level, and the township-level administrative level includes townships, towns and sub-districts;

[0097] If the first address information queried by the first query condition is the address information included in a township, town or sub-district, determine that the first level of the first address information is the village-level administrative level, and the village-level administrative level includes communities and villages.

[0098] In another possible implementation manner, based on the first query condition and each second query condition, acquire the corresponding first address information and each second address information from the database, including:

[0099] If the first level is the prefecture-level administrative level, obtain the address information corresponding to the prefecture-level administrative level and the second address information corresponding to the county-level administrative level from the database, and obtain the first address information from the address information corresponding to the prefecture-level administrative level; or, obtain the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, and the second address information corresponding to the township-level administrative level from the database, and obtain the first address information from the address information corresponding to the prefecture-level administrative level; or, obtain the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level from the database, and obtain the first address information from the address information corresponding to the prefecture-level administrative level, where the village-level administrative level includes communities and villages;

[0100] If the first level is the county-level administrative level, obtain the address information corresponding to the county-level administrative level and the second address information corresponding to the township-level administrative level from the database, and obtain the first address information from the address information corresponding to the county-level administrative level; or, obtain the address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level from the database, and obtain the first address information from the address information corresponding to the county-level administrative level;

[0101] If the first level is the township-level administrative level, obtain the address information corresponding to the township-level administrative level and the second address information corresponding to the village-level administrative level from the database, and obtain the first address information from the address information corresponding to the township-level administrative level.

[0102] In another possible implementation, based on the first query condition and each second query condition, obtain the corresponding first address information and each second address information from the database, including:

[0103] Send a second acquisition request to the database. The second acquisition request carries the first query condition and each second query condition. The database is used to obtain the corresponding first address information and each second address information based on the first query condition and each second query condition;

[0104] Receive the first address information and each second address information sent by the database.

[0105] In another possible implementation, in response to the first acquisition request for obtaining the second address information, obtain the second address information corresponding to the first acquisition request from the local, including:

[0106] In response to the first acquisition request, determine the first logical query statement for obtaining the second address information;

[0107] Determine the second address information from multiple local hierarchical matching trees based on the first logical query statement. In the hierarchical matching tree, the hierarchical level of the address information represented by the parent node is higher than that of the address information represented by the child node.

[0108] In another possible implementation, determining the second address information from multiple local hierarchical matching trees based on the first logical query statement includes:

[0109] Determine the address information with the highest hierarchical level and the address information with the lowest hierarchical level in the first logical query statement;

[0110] Based on the address information with the highest hierarchical level, determine the hierarchical matching tree with the top node being the address information with the highest hierarchical level as the target hierarchical matching tree from multiple local hierarchical matching trees;

[0111] Based on the address information with the lowest hierarchical level, determine the address information corresponding to the node with the address information with the lowest hierarchical level as the parent node in the target hierarchical matching tree as the second address information.

[0112] In another possible implementation, the process of determining the hierarchical matching tree includes:

[0113] Determine the address information that belongs to the same province, autonomous region, or municipality directly under the Central Government among the address information obtained from the database, and obtain the address information with an associated relationship;

[0114] Determine the address information that belongs to the same prefecture-level city or autonomous prefecture among the address information obtained from the database, and obtain the address information with an associated relationship;

[0115] Determine the address information that belongs to the same district, county-level city, or county among the address information obtained from the database, and obtain the address information with an associated relationship;

[0116] Determine the address information that belongs to the same township, town, or street among the address information obtained from the database, and obtain the address information with an associated relationship;

[0117] Determine the address information that belongs to the same community or village among the address information obtained from the database, and obtain the address information with an associated relationship;

[0118] Based on the address information with an associated relationship and the hierarchical level of each address information, connect two nodes to obtain the hierarchical matching tree.

[0119] In another possible implementation, the address information acquisition method further includes:

[0120] In response to receiving a notification message sent by the database, obtain the address information that has changed in the database from the notification message. The notification message is sent when the address information in the database changes;

[0121] Update the address information cached locally based on the changed address information in the database.

[0122] An embodiment of this application provides a method for obtaining address information. When obtaining the first address information, this method also obtains the second address information of a second level different from the first level according to the first level of the first address information, and caches the second address information locally. In this way, when obtaining the second address information, it can be directly obtained from the local, without the need to interact with the database again, saving time and thus improving the efficiency of obtaining address information.

[0123] In an embodiment of this application, if the electronic device is provided as a terminal and a server, the server obtains the address information from the database. After the server obtains the address information, it can cache the address information locally on the server, or send the address information to the terminal, and the terminal caches the address information locally on the terminal. Next, these two implementation manners will be introduced separately.

[0124] Figure 3 It is a flowchart of a method for obtaining address information provided by an embodiment of this application, which is executed by a terminal and a server. This embodiment is described by taking the server caching the address information locally on the server as an example. As Figure 3 shown, this method includes:

[0125] Step 301: The terminal sends a third acquisition request for acquiring the first address information to the server.

[0126] The first address information can be the address information included in any province, autonomous region or municipality directly under the Central Government, can be the address information included in any prefecture-level city or autonomous prefecture, can be the address information included in any district, county-level city or county. In the embodiment of this application, no specific limitation is made on the first address information.

[0127] In a possible implementation manner, the terminal displays a query interface, and a query box is displayed on the query interface. The number of the query boxes can be one or more. When the number of the query boxes is multiple, the multiple query boxes are used to query the address information of different levels one by one. For example, the number of the multiple query boxes is 5. The first query box is used to query the address information of the provinces, autonomous regions or municipalities directly under the Central Government included in the country. The second query box is used to query the address information included in the province, autonomous region or municipality directly under the Central Government in the first query box. The third query box is used to query the address information of the prefecture-level cities or autonomous prefectures corresponding to the first two query boxes. The fourth query box is used to query the address information of the districts, county-level cities or counties corresponding to the first three query boxes. The fifth query box is used to query the address information of the townships, towns and streets corresponding to the first four query boxes.

[0128] When the first query box is triggered, the terminal sends a fourth acquisition request to the server. The server obtains a third query condition from the fourth acquisition request, and this third query condition is used to query the address information of provinces, autonomous regions or municipalities directly under the Central Government included in the country. The server sends a fifth acquisition request to the database based on the third query condition. The database obtains all the address information of provinces, autonomous regions or municipalities directly under the Central Government based on this fifth acquisition request, returns all the address information of provinces, autonomous regions or municipalities directly under the Central Government to the server, and the server then returns all the address information of provinces, autonomous regions or municipalities directly under the Central Government to the terminal. The terminal displays all the address information of provinces, autonomous regions or municipalities directly under the Central Government on the interface. The user can select a target province, a target autonomous region or a target municipality directly under the Central Government from this address information of provinces, autonomous regions or municipalities directly under the Central Government. When the second query box is triggered, the terminal sends a third acquisition request to the server. The server receives the third acquisition request and executes step 302.

[0129] Among them, after the server obtains the address information of provinces, autonomous regions or municipalities directly under the Central Government, it can cache this address information locally. When obtaining it again later, there is no need to query the database again, which takes less time and has higher efficiency in obtaining address information.

[0130] In this implementation manner, the number of multiple query boxes can be 4. These 4 query boxes are respectively used to query the address information of provinces, autonomous regions or municipalities directly under the Central Government included in the country, the address information included in provinces, autonomous regions or municipalities directly under the Central Government, the address information included in prefecture-level cities or autonomous prefectures, and the address information included in districts, county-level cities or counties. Or, the number of multiple query boxes can be 3. These 3 query boxes are respectively used to query the address information of provinces, autonomous regions or municipalities directly under the Central Government included in the country, the address information included in provinces, autonomous regions or municipalities directly under the Central Government, and the address information included in prefecture-level cities or autonomous prefectures.

[0131] In the embodiments of the present application, the number of query boxes can be set and changed according to needs. For example, when a user signs up for an exam online and selects an exam location, and the exam location is set in different districts, county-level cities and counties of a prefecture-level city, in this case, the number of query boxes can be set to 3. Another example is that when a user gets vaccinated and detailed address information of the user is required, in this case, the number of query boxes can be set to 5.

[0132] In another possible implementation, a hierarchical address information is displayed on the terminal, and multiple query boxes are also displayed. The multiple query boxes are used to query the address information of different levels under this level one by one. For example, if the address information of the level displayed on the terminal is the address information of a province, the number of multiple query boxes can be 4. These 4 query boxes are respectively used to query the address information included in the prefecture-level cities or autonomous prefectures under this province, the address information included in a prefecture-level city or autonomous prefecture, the address information included in a district, county-level city or county, and the address information included in a township, town and street. When the first query box is triggered, the terminal sends a third acquisition request to the server, and the server receives the third acquisition request and executes step 302.

[0133] For another example, if the address information of the level displayed on the terminal is the address information of a prefecture-level city in a province, the number of multiple query boxes can be 3. These 3 query boxes are respectively used to query the address information included in this prefecture-level city, the address information included in a district, county-level city or county, and the address information included in a township, town and street. When the first query box is triggered, the terminal sends a third acquisition request to the server, and the server receives the third acquisition request and executes step 302.

[0134] For another example, if the address information of the level displayed on the terminal is the address information included in a district in a prefecture-level city of a province, the number of multiple query boxes can be 2. These 2 query boxes are respectively used to query the address information included in this district and the address information included in a township, town and street. When the first query box is triggered, the terminal sends a third acquisition request to the server, and the server receives the third acquisition request and executes step 302.

[0135] Step 302: The server responds to the third acquisition request and acquires a first query condition.

[0136] The third acquisition request carries third address information. The server determines the first query condition based on the third address information in the third acquisition request. The first query condition is used to query the first address information. For example, if the user wants to query which prefecture-level cities are included in Hebei Province through the terminal, the terminal sends a third acquisition request. The third acquisition request carries the address identifier of "Hebei Province", then the server determines the first query condition based on the address identifier of "Hebei Province" to query the address information included in Hebei Province.

[0137] Step 303: The server determines the first level of the first address information.

[0138] If the first address information queried by the first query condition is the address information included in a province, autonomous region, or municipality directly under the Central Government, determine that the first level of the first address information is the prefecture-level administrative level, which includes prefecture-level cities and autonomous prefectures. If the first address information queried by the first query condition is the address information included in a prefecture-level city or autonomous prefecture, determine that the first level of the first address information is the county-level administrative level, which includes districts, county-level cities, and counties. If the first address information queried by the first query condition is the address information included in a district, county-level city, or county, determine that the first level of the first address information is the township-level administrative level, which includes townships, towns, and sub-districts. If the first address information queried by the first query condition is the address information included in a township, town, or sub-district, determine that the first level of the first address information is the village-level administrative level, which includes communities and villages.

[0139] Thus, the server determines the address information with the lowest level from the first query condition, and uses the level one lower than this address information level as the first level. That is, if the first address information queried by the first query condition is the address information included in the provincial administrative level, and the level one lower than this provincial administrative level is the prefecture-level administrative level, then the first level of the first address information is the prefecture-level administrative level; if the first address information queried by the first query condition is the address information included in the prefecture-level administrative level, then the first level of the first address information is the county-level administrative level; if the first address information queried by the first query condition is the address information included in the county-level administrative level, then the first level of the first address information is the township-level administrative level. If the first address information queried by the first query condition is the address information included in the township-level administrative level, then the first level of the first address information is the village-level administrative level.

[0140] For example, if the first address information queried by the first query condition is the address information included in Hebei Province, and the only address information in this first query condition is "Hebei Province", and "Hebei Province" belongs to the provincial administrative level, and the level one lower than this provincial administrative level is the prefecture-level administrative level, then the server determines that the first level of the first address information is the prefecture-level administrative level. Another example, if the first address information queried by the first query condition is the address information included in Shijiazhuang City, Hebei Province, since the address information with the lowest level in the first query condition is "Shijiazhuang City", and "Shijiazhuang City" belongs to the prefecture-level administrative level, then the first level of the first address information is the county-level administrative level.

[0141] It should be noted that the provincial administrative level also includes special administrative regions. Here, only the provincial administrative level including provinces, autonomous regions, and municipalities directly under the Central Government is taken as an example for illustration. The prefecture-level administrative level also includes regions and leagues. Here, only the prefecture-level administrative level including prefecture-level cities and autonomous prefectures is taken as an example for illustration. The county-level administrative level also includes autonomous counties, autonomous banners, banners, and special zones. Here, only the county-level administrative level including districts, county-level cities, and counties is taken as an example for illustration. The township-level administrative level also includes ethnic townships, ethnic sumus, sumus, and town-level cities. Here, only the township-level administrative level including townships, towns, and sub-districts is taken as an example for illustration. The village-level administrative level also includes gachas. Here, only the village-level administrative level including communities and villages is taken as an example for illustration.

[0142] It should be noted that if the first level is the village-level administrative level, since the village-level administrative level is the lowest administrative level, the server can directly obtain the corresponding first address information from the database based on the first query condition. In this case, there is no need to determine the second level anymore.

[0143] Step 304: The server determines at least one second level lower than the first level based on the first level.

[0144] In the embodiments of the present application, the levels of the provincial administrative level, prefecture-level administrative level, county-level administrative level, township-level administrative level, and village-level administrative level are gradually from high to low.

[0145] The server can determine the level one level lower than the first level to obtain at least one second level, or can determine the levels one level and two levels lower than the first level to obtain at least one second level, or can determine all the levels lower than the first level to obtain at least one second level. Correspondingly, the third acquisition request also carries the scene information of the current scene. The server determines which level of address information is the address information that finally needs to be obtained based on the scene information of the current scene, then determines the difference between the first level and this level to obtain the level difference, and then takes the levels lower than the first level and with a level difference not greater than the corresponding level difference as at least one second level.

[0146] For example, if the first level is the prefecture-level administrative level and the level number is 1, then the second level is the county-level administrative level one level lower than the prefecture-level administrative level. Another example, if the first level is the prefecture-level administrative level and the level number is 2, then the second level is the county-level administrative level one level lower than the prefecture-level administrative level and the township-level administrative level two levels lower than the prefecture-level administrative level. Another example, if the first level is the prefecture-level administrative level and the level number is 3, then the second level is the county-level administrative level one level lower than the prefecture-level administrative level, the township-level administrative level two levels lower than the prefecture-level administrative level, and the village-level administrative level three levels lower than the prefecture-level administrative level. Another example, if the first level is the county-level administrative level and the level number is 1, then the second level is the township-level administrative level one level lower than the county-level administrative level.

[0147] Alternatively, the interface information of the current interface is also carried in the third acquisition request. Based on the interface information of the current interface, the server determines which level of address information is the final address information to be acquired, then determines the difference between the first level and this level to obtain the level difference, and then uses the level lower than the first level and with a level difference from the first level not greater than this level difference as at least one second level.

[0148] Alternatively, the server determines the number of query boxes to be queried in the current interface based on the interface information of the current interface, and determines the level difference based on the number of query boxes to be queried. Among them, the query boxes to be queried include the query box for querying the first address information. If the number of query boxes to be queried is 4, the level difference is determined to be 3. If the number of query boxes to be queried is 3, the level difference is determined to be 2. That is, the level difference is 1 less than the number of query boxes to be queried.

[0149] Step 305: The server determines at least one second query condition based on at least one second level.

[0150] The server uses at least one second level as at least one second query condition, and each second query condition is used to query the address information of one level.

[0151] Since the query of address information generally transitions from a high level to a low level gradually, in the embodiments of the present application, when acquiring the first address information, the second address information corresponding to the second level lower than the first level of the first address information is also acquired. In this way, when acquiring the address information of the second level later, there is no need to interact with the database again, shortening the response time, and thus improving the acquisition efficiency of the address information. Moreover, when acquiring the second address information based on the second level, there is no need to traverse the database to find out which address information corresponds to the first address information, which can further shorten the response time, and thus improve the acquisition efficiency of the address information.

[0152] Step 306: The server acquires the corresponding first address information and each second address information from the database based on the first query condition and each second query condition.

[0153] In this step, the server acquires the address information corresponding to the first level and the second address information corresponding to each second level from the database based on the first query condition and each second query condition, and then acquires the first address information from the address information corresponding to the first level.

[0154] That is, if the first level is the prefecture-level administrative level and the second level is the county-level administrative level, the server acquires the address information corresponding to the prefecture-level administrative level and the address information corresponding to the county-level administrative level from the database, and then acquires the first address information from the address information corresponding to the prefecture-level administrative level.

[0155] If the first level is the prefecture-level administrative level and the second level is the county-level administrative level and the township-level administrative level, the server obtains the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, and the second address information corresponding to the township-level administrative level from the database, and then obtains the first address information from the address information corresponding to the prefecture-level administrative level.

[0156] If the first level is the prefecture-level administrative level and the second level is the county-level administrative level, the township-level administrative level, and the village-level administrative level, the server obtains the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level from the database, and then obtains the first address information from the address information corresponding to the prefecture-level administrative level.

[0157] If the first level is the county-level administrative level and the second level is the township-level administrative level, the server obtains the address information corresponding to the county-level administrative level and the second address information corresponding to the township-level administrative level from the database, and then obtains the first address information from the address information corresponding to the county-level administrative level.

[0158] If the first level is the county-level administrative level and the second level is the township-level administrative level and the village-level administrative level, the server obtains the address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level from the database, and then obtains the first address information from the address information corresponding to the county-level administrative level.

[0159] If the first level is the township-level administrative level and the second level is the village-level administrative level, the server obtains the address information corresponding to the township-level administrative level and the second address information corresponding to the village-level administrative level from the database, and then obtains the first address information from the address information corresponding to the township-level administrative level.

[0160] In a possible implementation, when the server obtains the address information from the database, it sends a second acquisition request to the database. The second acquisition request carries a first query condition and each second query condition. The database receives the second acquisition request and, based on the first query condition and each second query condition, obtains the address information corresponding to the first level and the second address information corresponding to each second level, and then the database sends the address information corresponding to the first level and the second address information corresponding to each second level to the server.

[0161] In this implementation, the server can obtain the corresponding address information by interacting with the database only once, shortening the response time and thus improving the acquisition efficiency of the address information.

[0162] In the embodiments of the present application, different provinces, autonomous regions, and municipalities directly under the Central Government have different address identifiers. Different prefecture-level cities and autonomous prefectures under the same province, autonomous region, or municipality directly under the Central Government have different address identifiers. Different districts, county-level cities, and counties under the same prefecture-level city or autonomous prefecture also have different address identifiers. Different townships, towns, and sub-districts under the same district, county-level city, or county also have different address identifiers. Different villages and communities under the same township, town, or sub-district also have different address identifiers. Based on this, the server can obtain the address information corresponding to the address identifier from the address information corresponding to the first level based on the address identifier in the first address information, and obtain the first address information.

[0163] For example, the first address information queried by the first query condition is the address information included in Hebei Province. The first level is the prefecture-level administrative level, and the second level is the county-level administrative level and the township-level administrative level. The server obtains the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, and the second address information corresponding to the township-level administrative level from the database. Since the address information corresponding to the prefecture-level administrative level includes not only the address information under Hebei Province but also the address information under other provinces, in this case, the server obtains the address information under Hebei Province from the address information under Hebei Province and the address information under other provinces based on the address identifier of Hebei Province, that is, obtains the prefecture-level cities and autonomous prefectures included in Hebei Province.

[0164] In the embodiments of the present application, when querying the first address information, determine the first level of the first address information, obtain the address information based on the first level of the first address information, and then obtain the first address information from the address information corresponding to the first level. Since the address information at different levels in the database is regular, it is possible to parse whether the address information is a province or a city from the composition rule, and logically optimize the query SQL (Structured Query Language). By optimizing the SQL to query all address information such as provinces, cities, districts, and sub-districts, the fewer the conditions, the faster the SQL statement queries. In this way, there is no need to traverse the database to query the first address information, shortening the response time, and thus improving the query efficiency of the SQL statement.

[0165] Step 307: The server caches each second address information locally on the server.

[0166] After the server obtains each second address information, it can cache each second address information locally on the server, and can also cache the address information corresponding to the first level locally on the server.

[0167] In an embodiment of the present application, after the server obtains the address information from the database, it caches the address information locally on the server. In this way, when the address information is subsequently obtained, it can be directly obtained from the local server without the need to interact with the database, thereby shortening the response time and improving the efficiency of obtaining the address information.

[0168] One thing that needs to be explained is that after the server obtains the address information from the database, it can cache the address information locally on the server in the form of a hierarchical matching tree. The process can be:

[0169] The server determines that the address information obtained from the database belongs to the same province, autonomous region or municipality, and obtains address information with an associated relationship; determines that the address information obtained from the database belongs to the same prefecture-level city or autonomous prefecture, and obtains address information with an associated relationship; determines that the address information obtained from the database belongs to the same district, county-level city and county, and obtains address information with an associated relationship; determines that the address information obtained from the database belongs to the same township, town or street, and obtains address information with an associated relationship; determines that the address information obtained from the database belongs to the same community or village, and obtains address information with an associated relationship. The server connects two nodes based on the address information with an associated relationship and the hierarchy of each address information to obtain a hierarchical matching tree. In the hierarchical matching tree, the hierarchy of the address information represented by the parent node is higher than the hierarchy of the address information represented by the child node.

[0170] For example, Shijiazhuang City and Xingtai City are both address information under Hebei Province, Zhengzhou City and Kaifeng City are both address information under Henan Province, then Shijiazhuang City and Xingtai City are address information with associated relationship, and Zhengzhou City and Kaifeng City are address information with associated relationship. For another example, Zanhuang County and Xingtang County are both address information under Shijiazhuang City, Lankao County and Qi County are both address information under Kaifeng City, then Zanhuang County and Xingtang County are address information with associated relationship, and Lankao County and Qi County are address information with associated relationship.

[0171] The server determines through the above method that the address information with an associated relationship is address information belonging to the same level, but the address information locally cached by the server includes address information of different levels. In this case, the server uses the address information of two adjacent levels with an associated relationship as nodes, connects the two nodes, and obtains a hierarchical matching tree.

[0172] For example, Zanhuang County and Xingtang County are address information with an associated relationship. Both belong to the address information under Shijiazhuang City. Then, connect the nodes represented by Shijiazhuang City to the nodes represented by Zanhuang County and Xingtang County respectively. The level corresponding to Shijiazhuang City belongs to the prefecture-level administrative level, and the levels corresponding to Zanhuang County and Xingtang County belong to the county-level administrative level. Since the prefecture-level administrative level is higher than the county-level administrative level, the node represented by Shijiazhuang City serves as the parent node, and the nodes represented by Zanhuang County and Xingtang County serve as child nodes.

[0173] It should be noted that among the provincial administrative level, prefecture-level administrative level, county-level administrative level, township-level administrative level, and village-level administrative level, the provincial administrative level is the highest. Therefore, the server uses the address information corresponding to the provincial administrative level as the top node, and this top node can be used to identify the level matching tree. For example, both Shijiazhuang City and Xingtai City belong to the address information under Hebei Province, and Hebei Province belongs to the provincial administrative level. Then, the server uses the node represented by Hebei Province as the top node of the level matching tree.

[0174] In addition, since the address information cached locally by the server includes address information at each level under different provinces, autonomous regions, and municipalities directly under the Central Government, and there is no associated relationship between the address information at each level under different provinces, autonomous regions, and municipalities directly under the Central Government, multiple level matching trees can be obtained through the above method. For example, the address information at each level under Hebei Province forms a level matching tree, and the address information at each level under Henan Province forms another level matching tree.

[0175] In the embodiment of the present application, the server caches the address information locally in the form of a level matching tree based on the JavaScript flat-to-tree algorithm. Translated into Java code, it can reduce the algorithm complexity and is beneficial for subsequent querying of address information.

[0176] Step 308: The server returns the first address information to the terminal.

[0177] After the server obtains the first address information, it can return the first address information to the terminal, and the terminal displays the first address information on the query interface. For example, if the first address information is used to query the address information included in Hebei Province, the terminal displays the prefecture-level cities and autonomous prefectures included in Hebei Province on the query interface.

[0178] Step 309: The terminal sends a first acquisition request for obtaining the second address information to the server.

[0179] The user can select target address information from the query box that displays the first address information on the terminal, and then determine the address information included in the next query box based on the selected target address information. When the terminal detects that the next query box is triggered, it sends a first acquisition request to the server. For example, the first address information is used to query the address information included in Hebei Province. The terminal displays the prefecture-level cities included in Hebei Province, and the user selects the corresponding prefecture-level city from these prefecture-level cities. For example, the user selects Shijiazhuang City as the target address information, and then triggers the next query box, that is, to query the address information included in Shijiazhuang City. In this case, the terminal sends a first acquisition request to the server. Among them, the first acquisition request sent by the terminal to the server is used to acquire address information with the address information currently displayed on the terminal as a prerequisite.

[0180] Step 310: In response to the first acquisition request, the server acquires the second address information corresponding to the first acquisition request from the server local.

[0181] This step can be implemented through the following steps (1) to (2), including:

[0182] (1) In response to the first acquisition request, the server determines a first logical query statement for acquiring the second address information.

[0183] Based on the first acquisition request, the server determines a first logical query statement, and the first logical query statement includes address information at different levels. For example, if the address information currently displayed on the terminal is Hebei Province and Shijiazhuang City, then the address information carried in the first acquisition request is "Hebei Province" and "Shijiazhuang", and the first logical query statement is used to query the address information included in Shijiazhuang City, Hebei Province. Among them, "Hebei Province" and "Shijiazhuang City" belong to address information at different levels.

[0184] (2) The server determines the second address information from multiple hierarchical matching trees in the server local based on the first logical query statement.

[0185] Step (2) can be implemented through the following steps (2-1) to (2-3), including:

[0186] (2-1) The server determines the address information with the highest level and the address information with the lowest level in the first logical query statement based on the first logical query statement.

[0187] As can be seen from step (1), the first logical query statement includes address information at different levels. The server can determine the highest-level address information and the lowest-level address information based on the positions of the address information at different levels in the first logical query statement. The earlier the address information is in the first logical query statement, the higher its corresponding level. Therefore, the server takes the address information in the first position of the first logical query statement as the highest-level address information and the address information in the last position as the lowest-level address information.

[0188] For example, if the first logical query statement is used to query the address information included in Shijiazhuang City, Hebei Province, "Hebei Province" is in the most forward position, so "Hebei Province" is taken as the highest-level address information, and "Shijiazhuang City" is in the most backward position, so "Shijiazhuang City" is taken as the lowest-level address information. Another example, if the first logical query statement is used to query the address information included in Zanhuang County, Shijiazhuang City, Hebei Province, "Hebei Province" is in the most forward position, so "Hebei Province" is taken as the highest-level address information, and "Zanhuang County" is in the most backward position, so "Zanhuang County" is taken as the lowest-level address information.

[0189] (2-2) Based on the highest-level address information, the server determines, from multiple level matching trees in the server local, the level matching tree with the top node being the highest-level address information as the target level matching tree.

[0190] From the process of determining the level matching tree in step 307, it can be seen that the top node can be used to identify the level matching tree, and the node represented by the highest-level address information is the top node. Therefore, the server can search in multiple level matching trees for the level matching tree with the top node being the highest-level address information and take this level matching tree as the target level matching tree.

[0191] (2-3) Based on the lowest-level address information, the server determines, from the target level matching tree, the address information corresponding to the node with the lowest-level address information as the parent node as the second address information.

[0192] After the server determines the target level matching tree, it takes the node represented by the lowest-level address information as the parent node and determines the address information corresponding to the child nodes included in this parent node as the second address information.

[0193] Continuing with the example where the first logical query statement is used to query the address information included in Shijiazhuang City, Hebei Province, the server determines the target level matching tree corresponding to "Hebei Province" from multiple level matching trees corresponding to "Hebei Province", "Henan Province", "Shanxi Province", etc., and then determines, from the target level matching tree corresponding to "Hebei Province", the address information corresponding to multiple child nodes with "Shijiazhuang City" as the parent node, such as "Zanhuang County", "Xingtang County", etc., and takes the address information corresponding to these child nodes as the second address information.

[0194] In the embodiments of the present application, by performing a query based on a hierarchical matching tree and a logical query statement, the corresponding second address information can be quickly found locally, further shortening the response time and thus further improving the acquisition efficiency of the address information.

[0195] In the embodiments of the present application, the address information may change. Based on this, the server can update the address information cached locally every preset time period. The process is as follows: Determine the storage duration of the address information cached locally. When the storage duration reaches the preset time period, re-obtain the address information from the database, and based on the re-obtained address information, update the address information cached locally.

[0196] In this implementation manner, when the server determines that the storage duration reaches the preset time period, it can re-obtain the address information corresponding to the first level and the second address information corresponding to each second level from the database, then delete all the address information cached locally, and cache the re-obtained address information locally.

[0197] Alternatively, when the server determines that the storage duration reaches the preset time period, it re-obtains the address information corresponding to the first level and the second address information corresponding to each second level from the database, then determines the changed address information from the re-obtained address information, replaces the original address information with the changed address information, and then updates the address information cached locally.

[0198] Alternatively, when the server determines that the storage duration reaches the preset time period, it deletes the address information cached locally, and then when receiving a acquisition request sent by the terminal, based on the acquisition request, re-obtains the address information from the database and caches the re-obtained address information locally.

[0199] Among them, the preset time period can be set and changed as needed. For example, the preset time period is 5 minutes or 10 minutes. By setting a shorter preset time period, the real-time performance of address information update can be improved, ensuring that the address information obtained by the user is the latest address information.

[0200] In another possible implementation manner, the server updates the address information cached locally only when the address information in the database changes. The process is as follows: When the address information in the database changes, a notification message is sent to the server. In response to receiving the notification message sent by the database, the server obtains the address information that has changed in the database from the notification message; based on the address information that has changed in the database, the server updates the address information cached locally.

[0201] In this implementation mode, the address information in the local cache is updated only when the address information in the database changes. This can not only avoid repeatedly obtaining address information from the database and wasting resources, but also ensure that the address information obtained by the user is the latest address information.

[0202] In the embodiment of the present application, the server can also update the address information in the local cache in other ways, and no specific limitation is made thereto.

[0203] Step 311: The server returns the second address information to the terminal.

[0204] The server sends the second address information to the terminal, and the terminal displays the second address information on the query interface.

[0205] The server can obtain the second address information level by level based on the above method until the second address information at the lowest level is obtained, that is, the second address information corresponding to the village-level administrative level. Although the village-level administrative level is the lowest level, the address information at the village-level administrative level also includes more detailed address information. For example, the address information of the communities includes the address information of the residential areas. The address information in the database only covers the address information corresponding to the village-level administrative level. Based on this, the terminal can provide an input box on the query interface, and the input box is used to input detailed address information such as the address information of the residential area or the office building, so as to accurately obtain the address information of the user.

[0206] The embodiment of the present application provides an address information acquisition method. When acquiring the first address information, the method also acquires the second address information of the second level different from the first level according to the first level of the first address information, and caches the second address information locally. In this way, when acquiring the second address information, it can be directly obtained from the local, without interacting with the database again, saving time, and thus improving the acquisition efficiency of the address information.

[0207] Moreover, in the embodiment of the present application, the address information corresponding to the level is acquired from the database based on the level of the address information, rather than directly acquiring all the address information included in a province or all the address information included in a city from the database. For example, when directly acquiring the address information of the prefecture-level cities, districts, county-level cities, and counties, and the address information of townships, towns, and streets included in Hebei Province from the database, it needs to be implemented based on nested loops. This method needs to traverse the address information in the database and establish a cubic-level link with the database to achieve. Therefore, the time for this method to acquire address information is relatively long, and the algorithm complexity is relatively high.

[0208] The method provided by the embodiments of the present application is implemented based on the hierarchy of address information. When obtaining address information, it is not necessary to traverse the database. Only one logical query needs to be established to cache the address information locally, and then the construction of the hierarchical matching tree is completed, optimizing the original response time of 30 to 40 seconds to several hundred milliseconds, greatly improving the efficiency of obtaining address information.

[0209] Figure 4 It is a flowchart of a method for obtaining address information provided by the embodiments of the present application, which is executed by a terminal and a server. This embodiment is described by taking the terminal caching the address information to the local of the terminal as an example. As Figure 4 shown, the method includes:

[0210] Step 401: The terminal sends a third acquisition request for acquiring the first address information to the server.

[0211] Step 402: The server responds to the third acquisition request and acquires the first query condition.

[0212] Step 403: The server determines the first hierarchy of the first address information.

[0213] Step 404: The server determines the hierarchies lower than the first hierarchy based on the first hierarchy to obtain at least one second hierarchy.

[0214] Step 405: The server determines at least one second query condition based on at least one second hierarchy.

[0215] Steps 401 to 405 are the same as steps 301 to 305 respectively, and will not be elaborated here.

[0216] Step 406: The server acquires the address information corresponding to the first hierarchy and the second address information corresponding to each second hierarchy from the database based on the first query condition and each second query condition.

[0217] This step is the same as the step in which the server acquires the address information corresponding to the first hierarchy and the second address information corresponding to each second hierarchy in step 306, and will not be elaborated here.

[0218] Step 407: The server sends the address information corresponding to the first hierarchy and the second address information corresponding to each second hierarchy to the terminal.

[0219] Step 408: The terminal receives the address information corresponding to the first hierarchy and the second address information corresponding to each second hierarchy, acquires the first address information from the address information corresponding to the first hierarchy, and caches the second address information corresponding to each second hierarchy to the local of the terminal.

[0220] The process by which the terminal obtains the first address information from the address information corresponding to the first level is similar to the process by which the server obtains the first address information from the address information corresponding to the first level, which will not be elaborated here.

[0221] The process by which the terminal caches the second address information corresponding to each second level to the local of the terminal is similar to the process by which the server caches the second address information corresponding to each second level to the local of the server, which will not be elaborated here.

[0222] Among them, when the terminal caches the second address information corresponding to each second level to the local of the terminal, it also caches the address information corresponding to the first level to the local of the terminal.

[0223] Step 409: In response to the operation of obtaining the second address information, the terminal obtains the corresponding second address information from the local of the terminal.

[0224] After the terminal obtains the first address information from the address information corresponding to the first level, it can display the first address information. The user can select the target address information from the query box for displaying the first address information on the terminal, and then determine the address information included in the next query box based on the selected target address information. When the terminal detects that the next query box is triggered, it determines that the operation of obtaining the second address information is detected. In response to this obtaining operation, the terminal obtains the corresponding second address information from the local of the terminal.

[0225] Among them, the process by which the terminal obtains the second address information from the local of the terminal is similar to the process by which the server obtains the second address information from the local of the server in step 310, which will not be elaborated here.

[0226] In the embodiment of the present application, the terminal caches the address information corresponding to the first level and each second address information to the local of the terminal. In this way, the terminal can directly obtain the address information from the local of the terminal subsequently, without interacting with the server and the database anymore, shortening the response time, and thus improving the efficiency of obtaining the address information.

[0227] Figure 5 It is a schematic structural diagram of an address information obtaining device provided by an embodiment of the present application, as Figure 5 shown. The device includes:

[0228] A first obtaining module 501, configured to obtain a first query condition, where the first query condition is used to query the first address information;

[0229] A first determining module 502, configured to determine at least one second query condition based on the first level of the first address information, where each second query condition is used to query the second address information of one level, and the second level of the second address information is different from the first level of the first address information;

[0230] A second acquisition module 503, configured to acquire corresponding first address information and each second address information from a database based on a first query condition and each second query condition;

[0231] A cache module 504, configured to output the first address information and cache each second address information locally;

[0232] A third acquisition module 505, configured to, in response to a first acquisition request for acquiring second address information, acquire the second address information corresponding to the first acquisition request from local.

[0233] In a possible implementation manner, a first determination module 502 is configured to determine a first level of the first address information; based on the first level, determine levels lower than the first level to obtain at least one second level; and based on the at least one second level, determine at least one second query condition.

[0234] In another possible implementation manner, the first determination module 502 is configured to, if the first address information queried by the first query condition is address information included in a province, autonomous region, or municipality directly under the Central Government, determine that the first level of the first address information is the prefecture-level administrative level, and the prefecture-level administrative level includes prefecture-level cities and autonomous prefectures; if the first address information queried by the first query condition is address information included in a prefecture-level city or autonomous prefecture, determine that the first level of the first address information is the county-level administrative level, and the county-level administrative level includes districts, county-level cities, and counties; if the first address information queried by the first query condition is address information included in a district, county-level city, or county, determine that the first level of the first address information is the township-level administrative level, and the township-level administrative level includes townships, towns, and sub-districts; if the first address information queried by the first query condition is address information included in a township, town, or sub-district, determine that the first level of the first address information is the village-level administrative level, and the village-level administrative level includes communities and villages.

[0235] In another possible implementation, the second acquisition module 503 is configured to, if the first level is the prefecture-level administrative level, acquire the address information corresponding to the prefecture-level administrative level and the second address information corresponding to the county-level administrative level from the database, and acquire the first address information from the address information corresponding to the prefecture-level administrative level; or, acquire the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, and the second address information corresponding to the township-level administrative level from the database, and acquire the first address information from the address information corresponding to the prefecture-level administrative level; or, acquire the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level from the database, and acquire the first address information from the address information corresponding to the prefecture-level administrative level, where the village-level administrative level includes communities and villages; if the first level is the county-level administrative level, acquire the address information corresponding to the county-level administrative level and the second address information corresponding to the township-level administrative level from the database, and acquire the first address information from the address information corresponding to the county-level administrative level; or, acquire the address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level from the database, and acquire the first address information from the address information corresponding to the county-level administrative level; if the first level is the township-level administrative level, acquire the address information corresponding to the township-level administrative level and the second address information corresponding to the village-level administrative level from the database, and acquire the first address information from the address information corresponding to the township-level administrative level.

[0236] In another possible implementation, the second acquisition module 503 is configured to send a second acquisition request to the database, where the second acquisition request carries a first query condition and each second query condition, and the database is configured to acquire the corresponding first address information and each second address information based on the first query condition and each second query condition; and receive the first address information and each second address information sent by the database.

[0237] In another possible implementation, the third acquisition module 505 is configured to, in response to the first acquisition request, determine a first logical query statement for acquiring the second address information; and based on the first logical query statement, determine the second address information from multiple local hierarchical matching trees, where the hierarchical level of the address information represented by the parent node in the hierarchical matching tree is higher than the hierarchical level of the address information represented by the child node.

[0238] In another possible implementation, the third acquisition module 505 is configured to determine the highest-level address information and the lowest-level address information in the first logical query statement; based on the highest-level address information, determine, from multiple level matching trees locally, the level matching tree with the highest-level address information as the top node as the target level matching tree; based on the lowest-level address information, determine, from the target level matching tree, the address information corresponding to the node with the lowest-level address information as the parent node as the second address information.

[0239] In another possible implementation, the address information acquisition device further includes:

[0240] The second determination module is configured to determine the address information belonging to the same province, autonomous region or municipality directly under the Central Government among the address information obtained from the database, to obtain the address information with an associated relationship; determine the address information belonging to the same prefecture-level city or autonomous prefecture among the address information obtained from the database, to obtain the address information with an associated relationship; determine the address information belonging to the same district, county-level city or county among the address information obtained from the database, to obtain the address information with an associated relationship; determine the address information belonging to the same township, town or street among the address information obtained from the database, to obtain the address information with an associated relationship; determine the address information belonging to the same community or village among the address information obtained from the database, to obtain the address information with an associated relationship;

[0241] The third determination module is configured to connect two nodes based on the address information with an associated relationship and the level of each address information, to obtain a level matching tree.

[0242] In another possible implementation, the address information acquisition device further includes:

[0243] The fourth acquisition module is configured to, in response to receiving a notification message sent by the database, obtain the address information that has changed in the database from the notification message, where the notification message is sent when the address information in the database has changed;

[0244] The update module is configured to update the address information cached locally based on the address information that has changed in the database.

[0245] An embodiment of the present application provides an address information acquisition device. When acquiring the first address information, the device further acquires, according to the first level of the first address information, the second address information of a second level different from the first level, and caches the second address information locally. In this way, when acquiring the second address information, it can be directly obtained locally without interacting with the database again, saving time, thereby improving the acquisition efficiency of the address information.

[0246] It should be noted that: when the address information acquisition device provided in the above embodiment acquires address information, only the division of the above functional modules is used for illustration. In practical applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the electronic device is divided into different functional modules to complete all or part of the functions described above. In addition, the address information acquisition device provided in the above embodiment and the embodiment of the address information acquisition method belong to the same concept. For the specific implementation process, please refer to the method embodiment, which will not be elaborated here.

[0247] If the electronic device is provided as a terminal, refer to Figure 6 , Figure 6 which shows a block diagram of the structure of a terminal 600 provided by an exemplary embodiment of the present application. The terminal 600 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV) player, a notebook computer or a desktop computer. The terminal 600 may also be referred to by other names such as user equipment, portable terminal, laptop terminal, desktop terminal, etc.

[0248] Generally, the terminal 600 includes: a processor 601 and a memory 602.

[0249] The processor 601 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. The processor 601 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 601 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 601 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 601 may further include an AI (Artificial Intelligence) processor, and the AI processor is used to process computational operations related to machine learning.

[0250] The memory 602 may include one or more computer-readable storage media, and the computer-readable storage media may be non-transitory. The memory 602 may further include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In some embodiments, the non-transitory computer-readable storage media in the memory 602 is used to store at least one program code, and the at least one program code is used to be executed by the processor 601 to implement the address information acquisition method provided in the method embodiments of the present application.

[0251] In some embodiments, the terminal 600 may further optionally include: a peripheral device interface 603 and at least one peripheral device. The processor 601, the memory 602, and the peripheral device interface 603 may be connected by a bus or signal lines. Each peripheral device may be connected to the peripheral device interface 603 through a bus, signal lines, or a circuit board. Specifically, the peripheral devices include at least one of a radio frequency circuit 604, a display screen 605, a camera assembly 606, an audio circuit 607, a positioning component 608, and a power supply 609.

[0252] The peripheral device interface 603 can be used to connect at least one I / O (Input / Output) related peripheral device to the processor 601 and the memory 602. In some embodiments, the processor 601, the memory 602, and the peripheral device interface 603 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 601, the memory 602, and the peripheral device interface 603 can be implemented on a separate chip or circuit board, and this embodiment does not limit this.

[0253] The radio frequency circuit 604 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 604 communicates with a communication network and other communication devices through electromagnetic signals. The radio frequency circuit 604 converts an electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 604 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and so on. The radio frequency circuit 604 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: metropolitan area network, generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area network, and / or WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 604 may further include a circuit related to NFC (Near Field Communication), and this application does not limit this.

[0254] The display screen 605 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 605 is a touch display screen, the display screen 605 also has the ability to collect touch signals on or above the surface of the display screen 605. The touch signals can be input to the processor 601 as control signals for processing. At this time, the display screen 605 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, there can be one display screen 605, which is set on the front panel of the terminal 600; in some other embodiments, there can be at least two display screens 605, which are respectively set on different surfaces of the terminal 600 or are in a foldable design; in some other embodiments, the display screen 605 can be a flexible display screen, which is set on the curved surface or the folding surface of the terminal 600. Even further, the display screen 605 can also be set as an irregular non-rectangular shape, that is, a special-shaped screen. The display screen 605 can be prepared using materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).

[0255] The camera module 606 is used to collect images or videos. Optionally, the camera module 606 includes a front camera and a rear camera. Generally, the front camera is set on the front panel of the terminal, and the rear camera is set on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth-of-field camera, a wide-angle camera, and a telephoto camera respectively, to achieve functions such as the combination of the main camera and the depth-of-field camera to achieve the background blurring function, the combination of the main camera and the wide-angle camera to achieve panoramic shooting and VR (Virtual Reality) shooting functions or other combined shooting functions. In some embodiments, the camera module 606 can also include a flash. The flash can be a single-color-temperature flash or a two-color-temperature flash. The two-color-temperature flash refers to the combination of a warm-light flash and a cold-light flash, which can be used for light compensation under different color temperatures.

[0256] The audio circuit 607 may include a microphone and a speaker. The microphone is used to collect sound waves of the user and the environment, and convert the sound waves into electrical signals for input to the processor 601 for processing, or input to the radio frequency circuit 604 to enable voice communication. For the purpose of stereo collection or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 600. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert the electrical signals from the processor 601 or the radio frequency circuit 604 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for uses such as ranging. In some embodiments, the audio circuit 607 may also include a headphone jack.

[0257] The positioning component 608 is used to locate the current geographical location of the terminal 600 to achieve navigation or LBS (Location Based Service). The positioning component 608 may be a positioning component based on the GPS (Global Positioning System) of the United States, the Beidou system of China, the GLONASS system of Russia, or the Galileo system of the European Union.

[0258] The power supply 609 is used to supply power to each component in the terminal 600. The power supply 609 may be alternating current, direct current, a disposable battery, or a rechargeable battery. When the power supply 609 includes a rechargeable battery, the rechargeable battery may support wired charging or wireless charging. The rechargeable battery may also be used to support fast charging technology.

[0259] In some embodiments, the terminal 600 further includes one or more sensors 610. The one or more sensors 610 include, but are not limited to: an acceleration sensor 611, a gyroscope sensor 612, a pressure sensor 613, a fingerprint sensor 614, an optical sensor 615, and a proximity sensor 616.

[0260] The acceleration sensor 611 can detect the magnitudes of accelerations on the three coordinate axes of the coordinate system established with the terminal 600. For example, the acceleration sensor 611 can be used to detect the components of the gravitational acceleration on the three coordinate axes. The processor 601 can control the display screen 605 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 611. The acceleration sensor 611 can also be used for collecting game or user's motion data.

[0261] The gyroscope sensor 612 can detect the body orientation and rotation angle of the terminal 600. The gyroscope sensor 612 can cooperate with the acceleration sensor 611 to collect the 3D actions of the user on the terminal 600. Based on the data collected by the gyroscope sensor 612, the processor 601 can implement the following functions: motion sensing (such as changing the UI according to the user's tilting operation), image stabilization during shooting, game control, and inertial navigation.

[0262] The pressure sensor 613 can be disposed on the side frame of the terminal 600 and / or the lower layer of the display screen 605. When the pressure sensor 613 is disposed on the side frame of the terminal 600, it can detect the holding signal of the user on the terminal 600, and the processor 601 can perform left / right hand recognition or shortcut operations according to the holding signal collected by the pressure sensor 613. When the pressure sensor 613 is disposed on the lower layer of the display screen 605, the processor 601 can control the operable controls on the UI interface according to the pressure operation of the user on the display screen 605. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.

[0263] The fingerprint sensor 614 is used to collect the fingerprint of the user. The processor 601 can identify the user's identity according to the fingerprint collected by the fingerprint sensor 614, or the fingerprint sensor 614 can identify the user's identity according to the collected fingerprint. When the identified user identity is a trusted identity, the processor 601 authorizes the user to perform relevant sensitive operations, and the sensitive operations include unlocking the screen, viewing encrypted information, downloading software, making payments, and changing settings, etc. The fingerprint sensor 614 can be disposed on the front, back, or side of the terminal 600. When there are physical buttons or manufacturer Logos on the terminal 600, the fingerprint sensor 614 can be integrated with the physical buttons or manufacturer Logos.

[0264] The optical sensor 615 is used to collect the ambient light intensity. In one embodiment, the processor 601 can control the display brightness of the display screen 605 according to the ambient light intensity collected by the optical sensor 615. Specifically, when the ambient light intensity is high, the display brightness of the display screen 605 is increased; when the ambient light intensity is low, the display brightness of the display screen 605 is decreased. In another embodiment, the processor 601 can also dynamically adjust the shooting parameters of the camera module 606 according to the ambient light intensity collected by the optical sensor 615.

[0265] The proximity sensor 616, also known as a distance sensor, is typically disposed on the front panel of the terminal 600. The proximity sensor 616 is used to collect the distance between the user and the front of the terminal 600. In one embodiment, when the proximity sensor 616 detects that the distance between the user and the front of the terminal 600 is gradually decreasing, the processor 601 controls the display screen 605 to switch from the lit state to the off state; when the proximity sensor 616 detects that the distance between the user and the front of the terminal 600 is gradually increasing, the processor 601 controls the display screen 605 to switch from the off state to the lit state.

[0266] Those skilled in the art can understand that Figure 6 the structure shown in does not constitute a limitation on the terminal 600, and may include more or fewer components than shown in the figure, or combine some components, or adopt a different component layout.

[0267] If the electronic device is provided as a server, refer to Figure 7 , Figure 7 which is a block diagram of a structure of a server 700 provided by an embodiment of the present application. The server 700 may vary greatly due to different configurations or performances, and may include one or more processors (central processing units, CPUs) 701 and one or more memories 702. Among them, at least one program code is stored in the memory 702, and the at least one program code is loaded and executed by the processor 701 to implement the methods provided by the above various method embodiments. Of course, the server 700 may also have components such as wired or wireless network interfaces, keyboards, and input / output interfaces for input / output. The server 700 may also include other components for implementing the functions of the device, which will not be elaborated here.

[0268] If the electronic device is provided as a terminal and a server, the block diagrams of the terminal and the server can be respectively referred to Figure 6 and Figure 7 , which will not be elaborated here.

[0269] In an exemplary embodiment, a computer-readable storage medium is also provided. At least one program code is stored in the computer-readable storage medium, and the at least one program code is loaded and executed by a processor to implement the address information acquisition method in the embodiments of the present application.

[0270] In an exemplary embodiment, a computer program product is also provided. The computer program product includes computer program code, the computer program code is stored in a computer-readable storage medium, a processor of an electronic device reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code to enable the electronic device to execute the address information acquisition method in the embodiments of the present application.

[0271] In some embodiments, the computer program involved in the embodiments of the present application may be deployed to be executed on a computer device, or on multiple computer devices located at one place. Or, it may be executed on multiple computer devices distributed at multiple places and interconnected through a communication network. The multiple computer devices distributed at multiple places and interconnected through a communication network may form a blockchain system.

[0272] Those of ordinary skill in the art can understand that all or part of the steps to implement the above embodiments can be completed by hardware, or can be completed by instructing relevant hardware through a program. This program can be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a magnetic disk, an optical disc, or the like.

[0273] The above is only for the convenience of those skilled in the art to understand the technical solution of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. An address information acquisition method, characterized in that, the method includes: Obtain a first query condition, where the first query condition is used to query first address information; Determine the address information with the lowest level from the first query condition, and use the level that is one level lower than the level of the address information with the lowest level as the first level of the first address information; Determine the level difference between the first level and the level of the address information that finally needs to be obtained, and use the level that is lower than the first level and the level difference between it and the first level is not greater than the corresponding level difference as at least one second level; Use the at least one second level as at least one second query condition, and each second query condition is used to query second address information at one level, where the second level of the second address information is different from the first level of the first address information; Based on the first query condition and each second query condition, obtain the corresponding first address information and each second address information from the database; Output the first address information and cache each second address information locally; In response to a first acquisition request for obtaining second address information, obtain the second address information corresponding to the first acquisition request from the local.

2. The method according to claim 1, characterized in that, the determination of the first level of the first address information includes: If the first address information queried by the first query condition is the address information included in a province, autonomous region or municipality directly under the Central Government, determine that the first level of the first address information is the prefecture-level administrative level, and the prefecture-level administrative level includes prefecture-level cities and autonomous prefectures; If the first address information queried by the first query condition is the address information included in a prefecture-level city or autonomous prefecture, determine that the first level of the first address information is the county-level administrative level, and the county-level administrative level includes districts, county-level cities and counties; If the first address information queried by the first query condition is the address information included in a district, county-level city or county, determine that the first level of the first address information is the township-level administrative level, and the township-level administrative level includes townships, towns and sub-districts; If the first address information queried by the first query condition is the address information included in a township, town or sub-district, determine that the first level of the first address information is the village-level administrative level, and the village-level administrative level includes communities and villages.

3. The method according to claim 1, characterized in that, the obtaining of the corresponding first address information and each second address information from the database based on the first query condition and each second query condition includes: If the first level is the prefecture-level administrative level, obtain the address information corresponding to the prefecture-level administrative level and the second address information corresponding to the county-level administrative level from the database, and obtain the first address information from the address information corresponding to the prefecture-level administrative level; or, obtain the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, and the second address information corresponding to the township-level administrative level from the database, and obtain the first address information from the address information corresponding to the prefecture-level administrative level; or, obtain the address information corresponding to the prefecture-level administrative level, the second address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level from the database, and obtain the first address information from the address information corresponding to the prefecture-level administrative level, where the village-level administrative level includes communities and villages; If the first level is the county-level administrative level, obtain the address information corresponding to the county-level administrative level and the second address information corresponding to the township-level administrative level from the database, and obtain the first address information from the address information corresponding to the county-level administrative level; or, obtain the address information corresponding to the county-level administrative level, the second address information corresponding to the township-level administrative level, and the second address information corresponding to the village-level administrative level from the database, and obtain the first address information from the address information corresponding to the county-level administrative level; If the first level is the township-level administrative level, obtain the address information corresponding to the township-level administrative level and the second address information corresponding to the village-level administrative level from the database, and obtain the first address information from the address information corresponding to the township-level administrative level.

4. The method according to claim 1, wherein, the obtaining of the corresponding first address information and each second address information from the database based on the first query condition and each second query condition includes: sending a second acquisition request to the database, the second acquisition request carrying the first query condition and each second query condition, and the database being configured to obtain the corresponding first address information and each second address information based on the first query condition and each second query condition; receiving the first address information and each second address information sent by the database.

5. The method according to claim 1, wherein, the obtaining of the second address information corresponding to the first acquisition request from the local in response to the first acquisition request for obtaining the second address information includes: responding to the first acquisition request to determine a first logical query statement for obtaining the second address information; determining the second address information from multiple local hierarchical matching trees based on the first logical query statement, where the level of the address information represented by the parent node in the hierarchical matching tree is higher than the level of the address information represented by the child node.

6. The method according to claim 5, wherein, the determining of the second address information from multiple local hierarchical matching trees based on the first logical query statement includes: Determine the highest-level address information and the lowest-level address information in the first logical query statement; Based on the highest-level address information, determine, from multiple level matching trees locally, the level matching tree with the top node being the highest-level address information as the target level matching tree; Based on the lowest-level address information, determine, from the target level matching tree, the address information corresponding to the node with the lowest-level address information as the parent node as the second address information.

7. The method according to claim 5, wherein, the process of determining the level matching tree includes: Determine the address information that belongs to the same province, autonomous region or municipality directly under the Central Government among the address information obtained from the database, to obtain the address information with an associated relationship; Determine the address information that belongs to the same prefecture-level city or autonomous prefecture among the address information obtained from the database, to obtain the address information with an associated relationship; Determine the address information that belongs to the same district, county-level city or county among the address information obtained from the database, to obtain the address information with an associated relationship; Determine the address information that belongs to the same township, town or street among the address information obtained from the database, to obtain the address information with an associated relationship; Determine the address information that belongs to the same community or village among the address information obtained from the database, to obtain the address information with an associated relationship; Based on the address information with the associated relationship and the level of each address information, connect two nodes to obtain a level matching tree.

8. The method according to claim 1, wherein, the method further includes: In response to receiving a notification message sent by the database, obtain the address information that has changed in the database from the notification message, where the notification message is sent when the address information in the database changes; Based on the address information that has changed in the database, update the address information cached locally.

9. An address information acquisition device, wherein, the device includes: A first acquisition module, configured to acquire a first query condition, where the first query condition is used to query first address information; A first determination module, configured to determine the lowest-level address information from the first query condition, use the level one level lower than the level of the lowest-level address information as the first level of the first address information; determine the level difference between the first level and the level of the address information that ultimately needs to be acquired, and use the level lower than the first level and with a level difference not greater than the level difference corresponding to the first level as at least one second level; use the at least one second level as at least one second query condition, and each second query condition is used to query second address information at one level, where the second level of the second address information is different from the first level of the first address information; A second acquisition module, configured to acquire the corresponding first address information and each second address information from the database based on the first query condition and each second query condition; A cache module, configured to output the first address information and cache each second address information locally; A third acquisition module, configured to, in response to a first acquisition request for acquiring second address information, acquire the second address information corresponding to the first acquisition request from the local device.

10. An electronic device, wherein, the electronic device includes a processor and a memory, and at least one program code is stored in the memory and is loaded and executed by the processor to implement the address information acquisition method according to any one of claims 1 to 8.

11. A computer-readable storage medium, wherein, at least one program code is stored in the computer-readable storage medium and is loaded and executed by a processor to implement the address information acquisition method according to any one of claims 1 to 8.

12. A computer program product, wherein, the computer program product includes computer program code, the computer program code is stored in a computer-readable storage medium, a processor of an electronic device reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code so that the electronic device executes the address information acquisition method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Address input control method and device

    CN106296209A

  • Data query method and device, storage medium and electronic equipment

    CN111339140A