从我在您的问题中看到的,您只需要创建一个索引(MySQL 中的数据库模拟),在此索引中您将需要使用内容类型(如 MySQL 中的表)并且每本书都将是数据类型中的文档(类似于 MySQL 中的行)
你可以像这样添加你的书
POST library/books/ISBN-10:1449358543
{
"type": "Paperback",
"pages": 724,
"Publisher": "O'Reilly Media; 1 edition (Feb. 7 2015)",
"language": "English",
"tag": "Elasticsearch: The Definitive Guide Paperback – Feb 7 2015\nby Clinton Gormley (Author), Zachary Tong (Author)",
"desc": "Whether you need full-text search or real-time analytics of structured data—or both—the Elasticsearch distributed search engine is an ideal way to put your data to work. This practical guide not only shows you how to search, analyze, and explore data with Elasticsearch, but also helps you deal with the complexities of human language, geolocation, and relationships.\nIf you’re a newcomer to both search and distributed systems, you’ll quickly learn how to integrate Elasticsearch into your application. More experienced users will pick up lots of advanced techniques. Throughout the book, you’ll follow a problem-based approach to learn why, when, and how to use Elasticsearch features.\nUnderstand how Elasticsearch interprets data in your documents Index and query your data to take advantage of search concepts such as relevance and word proximity Handle human language through the effective use of analyzers and queries Summarize and group data to show overall trends, with aggregations and analytics Use geo-points and geo-shapes—Elasticsearch’s approaches to geolocation Model your data to take advantage of Elasticsearch’s horizontal scalability Learn how to configure and monitor your cluster in production"
}
您可以按任何字段搜索文档
POST library/books/_search
{
"query": {
"term": {
"language": {
"value": "english"
}
}
}
}
或任何字段组合
POST library/books/_search
{
"query": {
"bool": {
"should": [
{"term": {
"language": {
"value": "english"
}
}},
{"term": {
"type": {
"value": "paperback"
}
}}
]
}
}
}