The basic concept of full-text search
- Search
Search this behavior is a process user interaction with the search engines, you need to find some data, he provided a number of constraints to the search engine search engine to extract some of the results to the user through the constraints - Search engine
exists to search engines store, find and retrieve data using search engines is .Neo4jLucene
- Document
search software, the document is a first-class citizens. Store, search, display document are based on the core. Documents can be understood as simply a row of data in the database, but this line of data includes a field name. - Inverted index
inverted index search engine is the core data structure. In short, all the documents will become something like a book behind vocabularies. Be able to quickly find a word document from this data structure - Lucene search syntax
Query implementation | Purpose | Example |
---|---|---|
TermQuery | Word Match | Neo4j |
PhraseQuery | Phrase match | "graph database" |
RangeQuery | Range matching | [A to Z] {A to Z} |
WildcardQuery | Regular match | g*p?, d??abase |
PrefixQuery | Prefix match | something* |
FuzzyQuery | Suffix match | cipher~ |
BooleanQuery | Query polymerization | graph AND "shortest path" |
Preparing the Environment
- Container starts Neo4j
docker run -p 17687:7687 -p 17474:7474 --name=neo4j-test neo4j:3.5.3
- Create data, use test data.
:play northwind-graph
Neo4j full-text search
Neo4j full-text search has the following characteristics, but with the down I feel is most important to create an index statement is really just founded to name the control . Neo4j from start to default on 2.2.x era node_auto_indexing=true
. Inverted index at the time of data insertion has been created . create an index / delete an index of the cost is very small
- Support index relationship with the node
- It supports popular
analyzers
extensions - You can use
lucene query
the statement - Ratings can return query results
- Automatic updating of indexes
- Any single index number of documents
Index creation and deletion
The establishment of two indexes, one Product
index of the label. In addition a full database of full-text search index
call db.index.fulltext.createNodeIndex("all",['Product', 'Category', 'Supplier'],['reorderLevel', 'unitsInStock', 'unitPrice', 'supplierID', 'productID', 'discontinued', 'quantityPerUnit', 'categoryID', 'unitsOnOrder', 'productName', 'description', 'categoryName', 'picture', 'country', 'address', 'contactTitle', 'city', 'phone', 'contactName', 'postalCode', 'companyName', 'fax', 'region', 'homePage'])
call db.index.fulltext.createNodeIndex("product",['Product'],['reorderLevel', 'unitsInStock', 'unitPrice', 'supplierID', 'productID', 'quantityPerUnit', 'discontinued', 'productName', 'unitsOnOrder', 'categoryID'])
Delete Index
call db.index.fulltext.drop("all")
You can get all the tags and attributes through the function
call db.propertyKeys
call db.labels
Inquire
There's a very simple query. Just remember that a statement will be able to deal with most scenes
call db.index.fulltext.queryNodes(
'all', //这里索引名
'Av' // lucene查询语句
) yield node
where node.address contains "12" // where语句
return node
order by node.address // order skip limit
skip 0
limit 1
The basic concept of full-text search
- Search
Search this behavior is a process user interaction with the search engines, you need to find some data, he provided a number of constraints to the search engine search engine to extract some of the results to the user through the constraints - Search engine
exists to search engines store, find and retrieve data using search engines is .Neo4jLucene
- Document
search software, the document is a first-class citizens. Store, search, display document are based on the core. Documents can be understood as simply a row of data in the database, but this line of data includes a field name. - Inverted index
inverted index search engine is the core data structure. In short, all the documents will become something like a book behind vocabularies. Be able to quickly find a word document from this data structure - Lucene search syntax
Query implementation | Purpose | Example |
---|---|---|
TermQuery | Word Match | Neo4j |
PhraseQuery | Phrase match | "graph database" |
RangeQuery | Range matching | [A to Z] {A to Z} |
WildcardQuery | Regular match | g*p?, d??abase |
PrefixQuery | Prefix match | something* |
FuzzyQuery | Suffix match | cipher~ |
BooleanQuery | Query polymerization | graph AND "shortest path" |
Preparing the Environment
- Container starts Neo4j
docker run -p 17687:7687 -p 17474:7474 --name=neo4j-test neo4j:3.5.3
- Create data, use test data.
:play northwind-graph
Neo4j full-text search
Neo4j full-text search has the following characteristics, but with the down I feel is most important to create an index statement is really just founded to name the control . Neo4j from start to default on 2.2.x era node_auto_indexing=true
. Inverted index at the time of data insertion has been created . create an index / delete an index of the cost is very small
- Support index relationship with the node
- It supports popular
analyzers
extensions - You can use
lucene query
the statement - Ratings can return query results
- Automatic updating of indexes
- Any single index number of documents
Index creation and deletion
The establishment of two indexes, one Product
index of the label. In addition a full database of full-text search index
call db.index.fulltext.createNodeIndex("all",['Product', 'Category', 'Supplier'],['reorderLevel', 'unitsInStock', 'unitPrice', 'supplierID', 'productID', 'discontinued', 'quantityPerUnit', 'categoryID', 'unitsOnOrder', 'productName', 'description', 'categoryName', 'picture', 'country', 'address', 'contactTitle', 'city', 'phone', 'contactName', 'postalCode', 'companyName', 'fax', 'region', 'homePage'])
call db.index.fulltext.createNodeIndex("product",['Product'],['reorderLevel', 'unitsInStock', 'unitPrice', 'supplierID', 'productID', 'quantityPerUnit', 'discontinued', 'productName', 'unitsOnOrder', 'categoryID'])
Delete Index
call db.index.fulltext.drop("all")
You can get all the tags and attributes through the function
call db.propertyKeys
call db.labels
Inquire
There's a very simple query. Just remember that a statement will be able to deal with most scenes
call db.index.fulltext.queryNodes(
'all', //这里索引名
'Av' // lucene查询语句
) yield node
where node.address contains "12" // where语句
return node
order by node.address // order skip limit
skip 0
limit 1