Book Image

Lucene 4 Cookbook

By : Edwood Ng, Vineeth Mohan
Book Image

Lucene 4 Cookbook

By: Edwood Ng, Vineeth Mohan

Overview of this book

Table of Contents (16 chapters)
Lucene 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Searching the index


Elasticsearch has a flexible search interface; it allows you to search across multiple indexes and types, or limited to a specific index and/or type. The search interface supports the URL search with a query string as a parameter, or using a request body in a JSON format, in which you can use Elasticsearch's Query DSL (domain-specific language) to specify search components. We will go over both these approaches in this section.

How to do it...

Let's look at the following examples:

curl -XGET 'http://localhost:9200/news/article/_search?q=monday'

curl -XGET 'http://localhost:9200/news,news2/article/_search?q=monday'

curl -XGET 'http://localhost:9200/news/article,article2/_search?q=monday'

curl -XGET 'http://localhost:9200/news/_search?q=monday'

curl -XGET 'http://localhost:9200/_search?q=monday'

Each command represents different demonstrations of URI-based searches. We can in any combination of indexes and types. Assuming that we do have an existing document in the index...