我想了解一些关于弹性搜索的东西,想知道是否有人能帮我找出答案。
我面临的问题是,我应该维持多少个指数,如果存在太多的风险。让我说,我想在图书馆中索引书籍,并希望能够搜索:
据我所知,ES是一个文档存储引擎,这意味着数据类型是存储的,而不是标准化的RDMS结构。复杂的是,我是创建一种数据类型并将其存储,还是应该创建其他数据类型?
如何存储数据以便能够搜索以下组合:
我想知道我是否必须为每一章创建一个索引,然后每一章都有一个所有出版商的列表,这些出版商都有这本书的特征。
我把事情复杂化了吗?
发布于 2016-04-14 19:07:28
根据我在您的问题中看到的,您只需要创建一个索引(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"
}
}}
]
}
}
}https://stackoverflow.com/questions/36631554
复制相似问题