CN117453691A - Administrative region query method and device, electronic equipment and storage medium - Google Patents

Administrative region query method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117453691A
CN117453691A CN202311435989.4A CN202311435989A CN117453691A CN 117453691 A CN117453691 A CN 117453691A CN 202311435989 A CN202311435989 A CN 202311435989A CN 117453691 A CN117453691 A CN 117453691A
Authority
CN
China
Prior art keywords
node
administrative region
nodes
administrative
tree structure
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311435989.4A
Other languages
Chinese (zh)
Inventor
张德阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202311435989.4A priority Critical patent/CN117453691A/en
Publication of CN117453691A publication Critical patent/CN117453691A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/29Geographical information databases
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Remote Sensing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides an administrative region query method, an administrative region query device, electronic equipment and a storage medium, wherein the administrative region query method comprises the following steps: receiving administrative region keywords input by a user; according to the administrative region keywords, attribute information of all nodes pre-stored in a tree structure is called for matching to obtain target nodes containing administrative region keywords, wherein the tree structure is generated according to administrative region data in a preset administrative region file and different administrative region grades corresponding to the administrative region data, the tree structure comprises nodes of different levels, each node is used for storing administrative region data corresponding to the different administrative region grades, and each node comprises at least one attribute information; generating a query result according to attribute information of the target node, the father node and/or the child node; outputting a query result; that is, the embodiment of the application improves the searching efficiency and accuracy of the administrative region, and at the same time, the system is not excessively damaged in performance under the condition that the administrative region is required to be frequently searched.

Description

Administrative region query method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and apparatus for querying an administrative region, an electronic device, and a storage medium.
Background
With the rapid development of information technology, more and more data is collected and stored. Among them, administrative area data is often used as a basic data in various applications such as map navigation, address location, data statistics, and the like. However, with the continuous expansion of urban scale and the continuous appearance of new administrative divisions, the conventional administrative district search method cannot meet the requirements of modern society for this aspect.
The traditional administrative region retrieval method generally adopts a database-based query mode, and a large amount of data needs to be indexed and queried. The above-described query method may require a large amount of memory space and the query speed is also slow.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method, an apparatus, an electronic device, and a storage medium for querying an administrative region, so as to reduce a storage space and improve query efficiency. The specific technical scheme is as follows:
in a first aspect of the application, there is provided a method for querying an administrative area, the method including:
Receiving administrative region keywords input by a user;
matching according to attribute information of all nodes pre-stored in a tree structure of the administrative region keywords, and obtaining target nodes containing the administrative region keywords, wherein the tree structure is generated according to administrative region data in a preset administrative region file and different administrative region grades corresponding to the administrative region data, the tree structure comprises nodes of different grades, and each node is used for storing administrative region data corresponding to different administrative region grades;
if the target node has a father node and/or a child node, generating a query result according to the target node and attribute information of the father node and/or the child node corresponding to the target node;
and outputting the query result.
Optionally, before the step of receiving the administrative area keyword input by the user, the method includes:
acquiring a preset administrative region file, wherein the preset administrative region file comprises administrative region data corresponding to different administrative region grades;
constructing nodes of different levels in a tree structure according to the administrative region levels in the preset administrative region file, wherein the nodes comprise father nodes and child nodes of at least one level corresponding to the father nodes;
And filling the administrative region data in the preset administrative region file into the nodes corresponding to the tree structure according to the father node and the child node.
Optionally, the administrative district level includes a province level, a city level, and a county level.
Optionally, the node includes at least one attribute information, where the attribute information includes a region code, a current region node name, a current region node level, a current region full scale, a parent node full scale, and all child node full scales, and the current region node level is determined based on an administrative region level.
Optionally, the matching according to the attribute information of all the nodes pre-stored in the tree structure, the obtaining the target node including at least one hierarchy of the administrative region keyword includes:
and according to the administrative region keyword, calling the current region node names corresponding to all the nodes prestored in the tree structure to match, and obtaining the target node containing the administrative region keyword in the current region node name.
Optionally, if the target node has a parent node and/or a child node, generating the query result according to the target node and attribute information of the parent node and/or the child node corresponding to the target node includes:
Judging whether a father node and/or a child node exist in the target node;
if the target node has two father nodes, outputting the current area names corresponding to the target node, the father nodes and the father nodes of the father nodes respectively;
if the target node has one father node and one child node, outputting a current area full name corresponding to the target node, the father node and the child node respectively;
if the target node has two child nodes, outputting the target node, the child nodes and the current area names corresponding to the child nodes of the child nodes respectively;
and generating a query result according to the current area full name.
In still another aspect of the present invention, there is also provided an administrative area query apparatus, including:
the receiving module is used for receiving administrative region keywords input by a user;
the matching module is used for matching according to the attribute information of all nodes which are pre-stored in the administrative region keyword, so as to obtain a target node containing the administrative region keyword, wherein the tree structure is generated according to administrative region data in a preset administrative region file and different administrative region grades corresponding to the administrative region data, the tree structure comprises nodes of different levels, and each node is used for storing administrative region data corresponding to different administrative region grades;
The generation module is used for generating a query result according to the target node and attribute information of the father node and/or the child node corresponding to the target node if the father node and/or the child node exists in the target node;
and the output module is used for outputting the query result.
Optionally, the apparatus further includes:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring a preset administrative region file, and the preset administrative region file comprises administrative region data corresponding to different administrative region grades;
the determining module is used for constructing nodes of different levels in the tree structure according to the administrative region levels in the preset administrative region file, wherein the nodes comprise father nodes and child nodes of at least one level corresponding to the father nodes;
and the reading module is used for filling the administrative region data in the preset administrative region file into the nodes corresponding to the tree structure according to the father node and the child node.
Optionally, the matching module is further configured to use the administrative district level to include a province level, a city level, and a county level.
Optionally, the matching module is further configured to include at least one attribute information, where the attribute information includes a region code, a current region node name, a current region node level, a current region full scale, a parent node full scale, and all child node full scales.
Optionally, the matching module includes:
and the matching sub-module is used for matching the current area node names corresponding to all the nodes prestored in the tree structure according to the administrative area keyword call, so as to obtain the target node containing the administrative area keyword in the current area node name.
Optionally, the generating module includes:
the judging sub-module is used for judging whether the target node has a father node and/or a child node;
the first output sub-module is used for outputting the current area names corresponding to the target node, the father node and the father node of the father node respectively if the target node has two father nodes;
the second output sub-module is used for outputting the current area names respectively corresponding to the target node, the father node and the child node if the target node has one father node and one child node;
the third output sub-module is used for outputting the current area names corresponding to the target node, the sub-node and the sub-node of the sub-node respectively if the target node has two sub-nodes;
And the generation sub-module is used for generating a query result according to the current area full name.
In yet another aspect of the present application, there is provided an electronic device including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing any one of the administrative region query methods when executing the programs stored in the memory.
In yet another aspect of the application, there is also provided a computer readable storage medium having instructions stored therein, which when run on a computer, cause the computer to perform any of the above-described administrative area query methods.
In yet another aspect of the application implementation, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform any of the above-described administrative area query methods.
In the embodiment of the application, the tree structure is constructed through different administrative region grades corresponding to the data in the preset administrative region file, the tree structure comprises nodes with different levels, each node can store administrative region data corresponding to the different administrative region grades, and the association relationship between the nodes with different levels is stored as the tree structure, so that other level nodes related to the current node can be conveniently and quickly found. And by constructing the tree structure in the memory, all query operations can be further performed in the memory, compared with database query operations in the prior art, the query efficiency is remarkably improved, in addition, the database in the prior art cannot acquire all data by one-time query operation, multiple queries are required, the efficiency is lower, and even if multiple query operations are performed in the memory, the performance loss of a system is extremely low, so that the performance loss can be reduced during multiple queries. That is, the embodiment of the application can improve the retrieval efficiency and accuracy of the administrative region, and at the same time, the system is not excessively damaged in performance under the scene that the administrative region is required to be frequently queried.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
FIG. 1 is a flowchart illustrating steps of an administrative area query method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of an exemplary tree structure according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating steps of another method for querying an administrative area according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating steps of another method for querying an administrative area according to an embodiment of the present application;
fig. 5 is a block diagram of an administrative area query apparatus according to an embodiment of the present application;
fig. 6 is a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application, and although exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, as appropriate, such that embodiments of the present application may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of a type and not limited to the number of objects, e.g., the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
In various embodiments of the present application, it should be understood that the sequence numbers of the following processes do not mean the order of execution, and the order of execution of the processes should be determined by the functions and internal logic thereof, and should not constitute any limitation on the implementation process of the embodiments of the present application.
The administrative region query method, the administrative region query device, the electronic equipment, the administrative region query system and the administrative region query storage medium provided by the embodiment of the application are described in detail below by means of specific embodiments and application scenes of the specific embodiments with reference to the accompanying drawings.
It should be noted that, the application is applied to the memory of any terminal or server, and based on different application scenarios, the memory may be set in the server or terminal, for example, when a user performs an administrative region keyword query on a certain logistics platform, the query may be performed through a memory device set in the server required by the platform, and similarly, the memory may also be set in the memory of a certain terminal.
Referring to fig. 1, a flowchart of steps of a method for querying an administrative area according to an embodiment of the present invention may include:
step 101, receiving administrative region keywords input by a user;
it should be noted that, the administrative region is a region classified by administrative management, and the administrative region data is often used as a basic data in various applications, such as map navigation, address positioning, and data statistics.
Specifically, in an application scenario, when a user of a certain platform wants to query all level results of all administrative areas related to "morning sun", that is, query and search can be performed by using "morning sun" as an administrative area keyword at this time, so as to obtain all administrative areas including "evening sun".
102, matching according to attribute information of all nodes pre-stored in a tree structure of the administrative region keywords, to obtain target nodes containing the administrative region keywords, wherein the tree structure is generated according to administrative region data in a preset administrative region file and different administrative region grades corresponding to the administrative region data, the tree structure comprises nodes of different grades, each node is used for storing administrative region data corresponding to different administrative region grades, and each node comprises at least one attribute information;
after receiving the administrative region keywords input by the user in step 101, the matching may be performed according to the administrative region keywords from the attribute information of all the nodes in the preset tree structure, so as to obtain the nodes including the administrative region keywords.
It should be noted that each node in the tree structure corresponds to attribute information, where the attribute information includes an area code, a current area node name, a current area node level, a current area full scale, a parent node full scale, and all child node full scales, where the current area node level is determined based on an administrative area level.
For example, taking "130102, hebei province, shijia city, changan area" as an example, when this piece of administrative region data is read to a region-level node in the tree structure, 130102 is an administrative region code, followed by region names of 3 levels of province, city, region-level, and county, respectively, attribute information contained in each data node in the memory is a region code (130102), a current region node name (Changan area), a current region node level (3), a current region is fully named (Hebei province Shijia city Changan area), a father node is fully named (Hebei province Shijia city), and all child nodes are fully named (none), wherein the region node levels can be divided into a province level, a city level, and a region-level.
Further, matching may be performed among attribute information corresponding to all nodes in a tree structure stored in a memory in advance according to an administrative region keyword, when a current region node name in the attribute information corresponding to a node contains an administrative region keyword, it is indicated that the administrative region keyword is matched, and at this time, a target node containing the administrative region keyword is determined, but in order to query and output all administrative region data related to the administrative region keyword at one time, it is necessary to further determine whether or not a corresponding parent node and/or child node exists in the target node, and if so, it is determined according to attribute information corresponding to all nodes, respectively.
It should be noted that the administrative region data is obtained based on a preset administrative region file, and the file may be generated by retrieving and sorting big data, for example, may be derived from the latest administrative region division published by a statistics office or a related website, and is sorted into a file in a preset format according to the divided data.
Furthermore, the acquired administrative region file may include different administrative region data, where the different administrative region data corresponds to different administrative region levels, and in this embodiment of the present application, the administrative region levels corresponding to the administrative region data included in the administrative region file may include province level, city level, and county level.
Therefore, a tree structure may be constructed according to the administrative area file, as shown in fig. 2, fig. 2 is a schematic diagram of an exemplary tree structure provided in this embodiment of the present application, and it can be seen that a plurality of nodes included in the tree structure are provincial nodes, municipal nodes, and regional nodes, each node includes all attributes, and when the attributes do not exist, the node is empty or not, for example, the upper level of beijing city does not have a province, and then the attribute of the provincial node corresponding to beijing city is empty.
Specifically, the constructed tree structure includes multiple nodes, and the nodes have hierarchical association, for example, a father node is a province node, so that its child nodes may include child nodes formed by multiple cities below the province node level, and similarly, the child nodes of a city node may include child nodes or leaf nodes formed by multiple counties or regions corresponding to the cities.
In addition, after the administrative region data based on the tree structure is built through the memory in the terminal or the server, the tree structure built by the administrative region data is required to be stored, in the embodiment of the application, the memory is not required to be used for carrying out storage query based on the relational database, but can be used for carrying out query, so that the memory is not only a carrier for building the tree structure, but also a storage medium corresponding to the administrative region data in the tree structure, namely, the administrative region data in the built tree structure is stored in the memory, so that the subsequent query is carried out, wherein the storage structure corresponding to each node for storing the different administrative region data in the tree structure is of a key-value type, and when the query is carried out, the operation is simple, the query efficiency is high, and the time consumed by one query is only less than 1 millisecond.
For example, the preset administrative area file includes the following two pieces of data: 130000, hebei province; 130100, hebei province, shijia village.
The two pieces of data can be stored in the memory as follows:
key=northbound, value= { area code (130000), current area node name (northbound), current area node level (1), current area full scale (northbound), father node full scale (none), all child node full scale (northbound stoneware city, northbound tangshan city … …) };
key=stone home city in northland, value= { area code (130100), current area node name (stone home city), current area node level (2), current area full scale (stone home city in northland), father node full scale (northland), all child nodes full scale (city district in northland, long-term security area … … in stone home city in northland).
Namely, the storage structure corresponding to each node in the tree structure in the application is of a key-value type.
It should be noted that, in this embodiment of the present application, the memory is a memory bank of the machine, the data being used by the system or platform server interface is all placed in the memory, and the data is also stored in the memory before the document being edited is clicked and saved, so that the present application can improve the query efficiency by performing the query operation in the memory, that is, the data in the administrative region file is loaded into the memory, so that the query operation is performed without constructing a database, and the query efficiency is improved.
Further, after matching is performed according to the tree structure pre-stored in the memory according to the administrative region keyword, the node containing the administrative region keyword can be obtained.
Specifically, the nodes include attribute information corresponding to the nodes, and the nodes can be matched with keywords according to the attribute information, so that the nodes which contain administrative region keywords queried by the user are finally determined.
Step 103, if the target node has a parent node and/or a child node, generating a query result according to the target node and attribute information of the parent node and/or the child node corresponding to the target node.
And 104, outputting the query result.
For steps 103-104, after the target node containing the administrative area keyword has been determined in step 102, it is further determined whether the currently determined target node has a corresponding parent node and/or child node in the tree structure constructed based on the administrative area data.
Specifically, a query result may be generated according to the target node and attribute information corresponding to the parent node and/or the child node corresponding to the target node, and the query result may be output.
Specifically, the query result may be fed back to the platform where the user is located.
In the embodiment of the application, the tree structure is constructed through different administrative region grades corresponding to the data in the preset administrative region file, the tree structure comprises nodes with different levels, each node can store administrative region data corresponding to the different administrative region grades, and the association relationship between the nodes with different levels is stored as the tree structure, so that other level nodes related to the current node can be conveniently and quickly found. And by constructing the tree structure in the memory, all query operations can be further performed in the memory, compared with database query operations in the prior art, the query efficiency is remarkably improved, in addition, the database in the prior art cannot acquire all data by one-time query operation, multiple queries are required, the efficiency is lower, and even if multiple query operations are performed in the memory, the performance loss of a system is extremely low, so that the performance loss can be reduced during multiple queries. That is, the embodiment of the application can improve the retrieval efficiency and accuracy of the administrative region, and at the same time, the system is not excessively damaged in performance under the scene that the administrative region is required to be frequently queried.
Referring to fig. 3, a flowchart of steps of another administrative area query method according to an embodiment of the present invention may include:
step 201, acquiring a preset administrative region file, wherein the preset administrative region file comprises administrative region data corresponding to different administrative region grades;
step 202, constructing nodes of different levels in a tree structure according to the administrative region level in the preset administrative region file, wherein the nodes comprise father nodes and child nodes of at least one level corresponding to the father nodes;
and 203, filling the administrative region data in the preset administrative region file into the nodes corresponding to the tree structure according to the father node and the child node.
It should be noted that, in the foregoing steps 201 to 203, before the query can be implemented in the present application, a tree structure needs to be constructed according to the data in the preset administrative region file, and the administrative region data in the preset administrative region file is associated and stored through the tree structure.
Specifically, for the file of the preset administrative area, the relevant administrative data can be directly obtained through the relevant website and the data center, and the data are arranged into the file according to the preset format.
For example, the preset administrative area file is obtained from the relevant website, and the preset administrative area file may include the following data:
130000, hebei province; 130100, hebei province, shijia village; 130101, hebei province, shijia, city, district; 130102, hebei province, shijia, changan district; 130104, hebei province, shijia, qiaoxi.
Taking "130102, hebei province, shijia city, changan area" as an example, 130102 is an administrative region code, and the area names of 3 levels of province, city, county are respectively behind, and each data node contains these attribute information: region code, current region node name, current region node level, current region full scale, parent node full scale, and all child node full scales, namely region code (130102), current region node name (Changan district), current region node level (3), current region full scale (Changan district of Hebei province Shijia city), parent node full scale (Hebei province Shijia city), all child node full scales (none), wherein the region node levels can be divided into province level, city level, county level.
Therefore, the acquired administrative region file may include different data, where the different data corresponds to different dimensions, and in this embodiment, different administrative region levels corresponding to various administrative region data included in the administrative region file may include province, city, county, and the like.
Furthermore, according to the rule, the child node fills the administrative region data in the preset administrative region file into the node corresponding to the tree structure according to the father node.
Specifically, the tree structure constructed in the memory needs to determine the hierarchy in the tree structure, where the hierarchy may be determined according to the administrative region level corresponding to the administrative region data, for example, the administrative region level may be divided into a province level, a city level and a county level, where the current region node level corresponding to the province level may be represented as 1, the current region node level corresponding to the city level may be represented as 2, and the current region node level corresponding to the county level may be represented as 3.
And secondly, determining node attributes required by nodes in each hierarchy from the administrative region data according to the hierarchy, and filling the administrative region data in a preset administrative region file into the nodes corresponding to the tree structure.
Each node includes corresponding attribute information: the method comprises the steps of region codes, current region node names, current region node grades, current region full names, father node full names and all child node full names, wherein the current region node grades are determined based on administrative region grades.
Step 204, receiving administrative region keywords input by a user;
step 205, matching according to attribute information of all nodes pre-stored in a tree structure of the administrative region keywords, to obtain target nodes containing the administrative region keywords, wherein the tree structure is generated according to administrative region data in a preset administrative region file and different administrative region grades corresponding to the administrative region data, the tree structure comprises nodes of different grades, each node is used for storing administrative region data corresponding to different administrative region grades, and each node comprises at least one attribute information;
step 206, if the target node has a parent node and/or a child node, generating a query result according to the target node and attribute information of the parent node and/or the child node corresponding to the target node;
Step 207, outputting the query result.
It should be noted that, in the steps 204-207, reference is made to the foregoing descriptions, and no further description is provided herein.
In the embodiment of the application, the tree structure is constructed through different administrative region grades corresponding to the data in the preset administrative region file, the tree structure comprises nodes with different levels, each node can store administrative region data corresponding to the different administrative region grades, and the association relationship between the nodes with different levels is stored as the tree structure, so that other level nodes related to the current node can be conveniently and quickly found. And by constructing the tree structure in the memory, all query operations can be further performed in the memory, compared with database query operations in the prior art, the query efficiency is remarkably improved, in addition, the database in the prior art cannot acquire all data by one-time query operation, multiple queries are required, the efficiency is lower, and even if multiple query operations are performed in the memory, the performance loss of a system is extremely low, so that the performance loss can be reduced during multiple queries. That is, the embodiment of the application can improve the retrieval efficiency and accuracy of the administrative region, and at the same time, the system is not excessively damaged in performance under the scene that the administrative region is required to be frequently queried.
In addition, in the embodiment of the application, although the database in the prior art supports various query conditions, the efficiency is lower, the time for one query is tens of milliseconds or even hundreds of milliseconds, the storage medium used in the application is a memory, the storage structure is of key-value type, the structure is simple, the query efficiency is high, the time for one query is less than 1 millisecond, therefore, the embodiment of the application builds a tree structure, the tree structure is stored in the memory, the query of related data of any administrative region in the follow-up process is the tree structure in the memory, the database and the file query are not required to be relied on, and the search efficiency is improved.
Referring to fig. 4, a flowchart of steps of another administrative area query method according to an embodiment of the present invention may include:
step 301, receiving administrative region keywords input by a user;
it should be noted that, in the step 301, reference is made to the foregoing discussion, and a detailed description is omitted here.
Step 302, according to the administrative region keyword call, matching is performed on the current region node names corresponding to all the nodes pre-stored in the tree structure, so as to obtain a target node containing the administrative region keyword in the current region node names;
Step 303, judging whether a parent node and/or a child node exist in the target node;
step 304, if the target node has two father nodes, outputting the current area names corresponding to the target node, the father nodes and the father nodes of the father nodes respectively;
step 305, if the target node has one parent node and one child node, outputting a full name of the current areas corresponding to the target node, the parent node and the child node respectively;
step 306, if the target node has two child nodes, outputting the target node, the child nodes and the current area names corresponding to the child nodes of the child nodes respectively;
and step 307, generating a query result according to the current area full name.
Step 308, outputting the query result.
It should be noted that, the foregoing has explained the attribute information included in each node, that is, in steps 302-307, each node includes the corresponding attribute information, where the attribute information includes the area code, the current area node name, the current area node level, the current area full name, the parent node full name, and all the child node full names.
Therefore, according to the administrative region keywords, matching is performed in attribute information corresponding to all the nodes in a tree structure stored in a memory in advance to obtain a target node where the administrative region keywords are located, wherein in the embodiment of the application, when the node determining whether the matching is that the current region node name in the attribute information corresponding to the current node contains the administrative region keywords, the current node represents that the administrative region keywords are matched, and then the current node is the target node containing the administrative region keywords.
Further, after determining the target node, it is required to determine whether the target node has a parent node and/or a child node, and then generate a query result according to the target node, the parent node corresponding to the target node, and/or the child node corresponding to the target node as a node matched with the administrative region keyword, and according to the node and the node attribute information.
For the father node and the child node, for example, when the target node is a city level, the father node corresponding to the target node is a province level, and the child node is a county level, so that for the target node, if the target node has a corresponding father node or child node when the current area node level corresponding to the target node is a county level, the father node of the target node is determined according to the father node full name in the attribute information of the target node, otherwise, if the target node has a corresponding child node when the current area node level corresponding to the target node is a province level, the child node of the target node is determined according to all child nodes in the attribute information of the target node full names.
If the current regional node level corresponding to the target node is the city level, at the moment, the target node has child nodes and parent nodes, and the parent nodes and the child nodes of the target node are determined according to the full names of the parent nodes and the full names of all the child nodes in the attribute information of the target node.
It should be noted that, when the query result is output, the required attribute information is the current area full scale, and finally the query result is generated according to the current area full scale corresponding to the target node and the father node and/or the child node thereof.
In addition, in addition to the current regional title, the user may view attribute information for each of the target node and its parent and/or child nodes.
Specifically, continuing taking "morning sun" as an example of an administrative region keyword, firstly removing attribute information in a matching node in a memory according to the keyword, for example, the attribute information can comprise a region code, a current region node name, a current region node level, a current region full scale, a father node full scale and all child node full scales, so that all the current region node names matched in the memory according to the administrative region keyword comprise nodes of "morning sun", if the matched nodes belong to a county level, searching nodes of the city level and corresponding attribute information according to the father node full scale attribute of the current node, and then searching the nodes of the provincial level and the corresponding attribute information in the same way; if the matched node belongs to the city level, besides searching the attribute of the father node, searching the attribute of all child nodes, and obtaining node information of all county levels contained in the node.
In the embodiment of the application, the query of the target node and the corresponding father node and child node can be realized through the father node full name and all child node full names in the attribute information corresponding to each node.
Illustratively, the results of the final search for "morning sun" keywords match are as follows:
"110105, beijing Kogyang area;
220104 Jilin Changchun Kong Yangzhang region;
211300, chaoyang, liaoning province;
211301 the district of the Chaoyang city of Liaoning province;
211302, double tower region of the Chaoyang city of Liaoning province;
211303A, keyang, dragon and city area of Liaoning;
211321 the Chaoyang city, chaoyang county, liaoning province;
211322, jian Ping county of Chaoyang city of Liaoning province;
211324 the Kidney-free Kaiyang City Kara-Qing left wing Mongolian county;
211381 the number of the individual pieces of the plastic, north Ticket City of Qianyang City of Liaoning province;
211382 Lingyuan city, kogyang city of Liaoning province).
In addition, in the embodiment of the present application, after a user inputs a keyword, multiple queries may be performed, where the query in the embodiment of the present application is different from the conventional database query in that the query link is shortened and the efficiency provided by the storage medium is different, for example, in the example from the user initiating the query request to receiving the response data, 10 queries are required to query the storage medium.
For the purposes of this application, since the tree structure is stored in the memory, the query link in this embodiment of the application is: user initiated request, network transmission, query service, memory query 10 times, network transmission, user receiving response data.
The traditional database query links are: the user initiates a request, network transmission, query service, the link in brackets (network transmission, database file, network transmission, query service) is repeated 10 times, network transmission, and the user receives response data.
Therefore, in the embodiment of the application, a tree structure is constructed by presetting different administrative region grades corresponding to data in an administrative region file, the tree structure comprises different hierarchy nodes, each node can store administrative region data corresponding to the different administrative region grades, and the association relationship between the different hierarchy nodes is stored as the tree structure, so that other hierarchy nodes related to the current node can be conveniently and quickly found. And by constructing the tree structure in the memory, all query operations can be further performed in the memory, compared with database query operations in the prior art, the query efficiency is remarkably improved, in addition, the database in the prior art cannot acquire all data by one-time query operation, multiple queries are required, the efficiency is lower, and even if multiple query operations are performed in the memory, the performance loss of a system is extremely low, so that the performance loss can be reduced during multiple queries. That is, the embodiment of the application can improve the retrieval efficiency and accuracy of the administrative region, and at the same time, the system is not excessively damaged in performance under the scene that the administrative region is required to be frequently queried.
In addition, in the embodiment of the application, when the user inputs the administrative region keyword, the node and the child node containing the keyword are matched from the administrative region tree structure according to the keyword. In matching, fuzzy matching and multi-stage matching are adopted, namely, the input keywords are allowed to be successfully matched at any position of the node names, and the matching result can comprise nodes of a plurality of levels. After the matching is finished, the matched nodes are returned to the user to form a query result, namely, in the embodiment of the application, the association relations among all the nodes are stored as a tree structure, and other level nodes related to the current node can be quickly found by using the tree structure.
In addition, in the embodiment of the application, each node contains attribute information, namely region codes and region names when the tree structure is constructed, the node containing the key words can be determined according to the attribute information in the node when matching is carried out later, and the corresponding attribute information is displayed to the user again, so that the user can acquire the query result quickly and intuitively.
Referring to fig. 5, fig. 5 is a block diagram illustrating a structure of an administrative area query apparatus according to an embodiment of the present invention, where the apparatus may include:
A receiving module 401, configured to receive administrative region keywords input by a user;
the matching module 402 is configured to call attribute information of all nodes pre-stored in a tree structure according to the administrative region keyword to obtain a target node containing the administrative region keyword, where the tree structure is generated according to administrative region data in a preset administrative region file and different administrative region levels corresponding to the administrative region data, the tree structure includes nodes of different levels, and each node is configured to store administrative region data corresponding to different administrative region levels;
a generating module 403, configured to generate a query result according to the target node and attribute information of a parent node and/or a child node corresponding to the target node if the target node has the parent node and/or the child node;
and the output module 404 is configured to output the query result.
Optionally, the apparatus further includes:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring a preset administrative region file, and the preset administrative region file comprises administrative region data corresponding to different administrative region grades;
the determining module is used for constructing nodes of different levels in the tree structure according to the administrative region levels in the preset administrative region file, wherein the nodes comprise father nodes and child nodes of at least one level corresponding to the father nodes;
And the reading module is used for filling the administrative region data in the preset administrative region file into the nodes corresponding to the tree structure according to the father node and the child node.
Optionally, the matching module is further configured to use the administrative district level to include a province level, a city level, and a county level.
Optionally, the matching module is further configured to include at least one attribute information, where the attribute information includes a region code, a current region node name, a current region node level, a current region full scale, a parent node full scale, and all child node full scales.
Optionally, the matching module includes:
and the matching sub-module is used for matching the current area node names corresponding to all the nodes prestored in the tree structure according to the administrative area keyword call, so as to obtain the target node containing the administrative area keyword in the current area node name.
Optionally, the generating module includes:
the judging sub-module is used for judging whether the target node has a father node and/or a child node;
the first output sub-module is used for outputting the current area names corresponding to the target node, the father node and the father node of the father node respectively if the target node has two father nodes;
The second output sub-module is used for outputting the current area names respectively corresponding to the target node, the father node and the child node if the target node has one father node and one child node;
the third output sub-module is used for outputting the current area names corresponding to the target node, the sub-node and the sub-node of the sub-node respectively if the target node has two sub-nodes;
and the generation sub-module is used for generating a query result according to the current area full name.
In the embodiment of the application, the tree structure is constructed through different administrative region grades corresponding to the data in the preset administrative region file, the tree structure comprises nodes with different levels, each node can store administrative region data corresponding to the different administrative region grades, and the association relationship between the nodes with different levels is stored as the tree structure, so that other level nodes related to the current node can be conveniently and quickly found. And by constructing the tree structure in the memory, all query operations can be further performed in the memory, compared with database query operations in the prior art, the query efficiency is remarkably improved, in addition, the database in the prior art cannot acquire all data by one-time query operation, multiple queries are required, the efficiency is lower, and even if multiple query operations are performed in the memory, the performance loss of a system is extremely low, so that the performance loss can be reduced during multiple queries. That is, the embodiment of the application can improve the retrieval efficiency and accuracy of the administrative region, and at the same time, the system is not excessively damaged in performance under the scene that the administrative region is required to be frequently queried.
The embodiment of the invention also provides an electronic device, as shown in fig. 6, which comprises a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602 and the memory 603 complete communication with each other through the communication bus 604,
a memory 603 for storing a computer program;
the processor 601, when executing the program stored in the memory 603, may implement the following steps:
receiving administrative region keywords input by a user;
matching according to attribute information of all nodes pre-stored in a tree structure of the administrative region keywords, and obtaining target nodes containing the administrative region keywords, wherein the tree structure is generated according to administrative region data in a preset administrative region file and different administrative region grades corresponding to the administrative region data, the tree structure comprises nodes of different grades, each node is used for storing administrative region data corresponding to different administrative region grades, and each node comprises at least one attribute information;
if the target node has a father node and/or a child node, generating a query result according to the target node and attribute information of the father node and/or the child node corresponding to the target node;
And outputting the query result.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment provided herein, there is also provided a computer readable storage medium having instructions stored therein that, when run on a computer, cause the computer to perform the administrative area query of any one of the embodiments described above.
In yet another embodiment provided herein, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform the administrative area query of any one of the embodiments described above.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or third database to another website, computer, server, or third database by a wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device including one or more servers, third databases, etc. that can be integrated with the available medium. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the scope of the present application. Any modifications, equivalent substitutions, improvements, etc. that are within the spirit and principles of the present application are intended to be included within the scope of the present application.

Claims (10)

1. An administrative area query method, the method comprising:
receiving administrative region keywords input by a user;
matching according to attribute information of all nodes pre-stored in a tree structure of the administrative region keywords, and obtaining target nodes containing the administrative region keywords, wherein the tree structure is generated according to administrative region data in a preset administrative region file and different administrative region grades corresponding to the administrative region data, the tree structure comprises nodes of different grades, each node is used for storing administrative region data corresponding to different administrative region grades, and each node comprises at least one attribute information;
if the target node has a father node and/or a child node, generating a query result according to the target node and attribute information of the father node and/or the child node corresponding to the target node;
And outputting the query result.
2. The administrative area query method according to claim 1, wherein before the step of receiving administrative area keywords input by a user, the method includes:
acquiring a preset administrative region file, wherein the preset administrative region file comprises administrative region data corresponding to different administrative region grades;
constructing nodes of different levels in a tree structure according to the administrative region levels in the preset administrative region file, wherein the nodes comprise father nodes and child nodes of at least one level corresponding to the father nodes;
and filling the administrative region data in the preset administrative region file into the nodes corresponding to the tree structure according to the father node and the child node.
3. The administrative district query method according to claim 1 or 2, wherein the administrative district level includes a province level, a city level, and a county level.
4. The administrative area query method according to claim 1, wherein the attribute information includes an area code, a current area node name, a current area node level, a current area full scale, a parent node full scale, and all child node full scales, wherein the current area node level is determined based on an administrative area level.
5. The administrative area query method according to claim 4, wherein the matching the attribute information of all nodes pre-stored in the tree structure according to the administrative area keyword call, to obtain a target node of at least one hierarchy level containing the administrative area keyword includes:
and according to the administrative region keyword, calling the current region node names corresponding to all the nodes prestored in the tree structure to match, and obtaining the target node containing the administrative region keyword in the current region node name.
6. The administrative region query method according to claim 5, wherein if the target node has a parent node and/or a child node, generating a query result according to attribute information of the target node and the parent node and/or the child node corresponding to the target node includes:
judging whether a father node and/or a child node exist in the target node;
if the target node has two father nodes, outputting the current area names corresponding to the target node, the father nodes and the father nodes of the father nodes respectively;
if the target node has one father node and one child node, outputting a current area full name corresponding to the target node, the father node and the child node respectively;
If the target node has two child nodes, outputting the target node, the child nodes and the current area names corresponding to the child nodes of the child nodes respectively;
and generating a query result according to the current area full name.
7. An administrative area query apparatus, the apparatus comprising:
the receiving module is used for receiving administrative region keywords input by a user;
the matching module is used for matching according to the attribute information of all nodes which are pre-stored in the administrative region keyword, so as to obtain a target node containing the administrative region keyword, wherein the tree structure is generated according to administrative region data in a preset administrative region file and different administrative region grades corresponding to the administrative region data, the tree structure comprises nodes of different levels, and each node is used for storing administrative region data corresponding to different administrative region grades;
the generation module is used for generating a query result according to the target node and attribute information of the father node and/or the child node corresponding to the target node if the father node and/or the child node exists in the target node;
And the output module is used for outputting the query result.
8. The administrative area query apparatus of claim 7, wherein the apparatus comprises:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring a preset administrative region file, and the preset administrative region file comprises administrative region data corresponding to different administrative region grades;
the determining module is used for constructing nodes of different levels in the tree structure according to the administrative region levels in the preset administrative region file, wherein the nodes comprise father nodes and child nodes of at least one level corresponding to the father nodes;
and the reading module is used for filling the administrative region data in the preset administrative region file into the nodes corresponding to the tree structure according to the father node and the child node.
9. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-6 when executing a program stored on a memory.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method steps of any of claims 1-6.
CN202311435989.4A 2023-10-31 2023-10-31 Administrative region query method and device, electronic equipment and storage medium Pending CN117453691A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311435989.4A CN117453691A (en) 2023-10-31 2023-10-31 Administrative region query method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311435989.4A CN117453691A (en) 2023-10-31 2023-10-31 Administrative region query method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117453691A true CN117453691A (en) 2024-01-26

Family

ID=89594400

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311435989.4A Pending CN117453691A (en) 2023-10-31 2023-10-31 Administrative region query method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117453691A (en)

Similar Documents

Publication Publication Date Title
CN111309868B (en) Knowledge graph construction and retrieval method and device
CN112672370B (en) Method, system, equipment and storage medium for automatically detecting network element index data
CN111506621A (en) Data statistical method and device
CN114491172B (en) Rapid retrieval method, device and equipment for tree structure nodes and storage medium
CN111813744A (en) File searching method, device, equipment and storage medium
CN111125199B (en) Database access method and device and electronic equipment
CN115563409A (en) Address administrative division identification method, device, equipment and medium
CN111984673B (en) Fuzzy retrieval method and device for tree structure of power grid electric energy metering system
CN105302827A (en) Event search method and device
CN114138877A (en) Method, device and equipment for realizing theme data service based on micro-service architecture
CN103500222A (en) Method and device for searching for chat object through communication software
CN110427538B (en) Data query method, data storage method, data query device, data storage device and electronic equipment
CN113282579A (en) Heterogeneous data storage and retrieval method, device, equipment and storage medium
CN117453691A (en) Administrative region query method and device, electronic equipment and storage medium
CN111813773A (en) Power grid meter reading data storage method, uploading method, device and storage device
CN113076330B (en) Query processing method, device, database system, electronic equipment and storage medium
CN113868138A (en) Method, system, equipment and storage medium for acquiring test data
CN110928868B (en) Vehicle data retrieval method, device and computer readable storage medium
CN111552856A (en) Microblog public opinion propagation path analysis method
US7155503B2 (en) Data server
CN107180072B (en) Method and device for processing time sequence data
CN117271480B (en) Data processing method, device, electronic equipment and medium
CN109905475B (en) Method for outputting cloud computing monitoring data in specified format based on SQL
CN110232063B (en) Hierarchical data query method, hierarchical data query device, computer equipment and storage medium
CN117725058A (en) Data blood-margin management system and data blood-margin management method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination