Elasticsearch is used by users to implement advanced search capabilities across various platforms. It helps businesses enhance user experiences by providing relevant and fast search results for websites, applications, and internal data. Users leverage its features for ecommerce, customer support, and workplace search, benefiting from semantic search, customizable relevance, and scalable performance. The solution allows for tailored search experiences, improving data accessibility and user engagement.
Learn more about Elasticsearch at https://www.elastic.co/enterprise-search
Use the curl
command to check if the ElasticSearch server is responding:
curl -X GET "<http://localhost:9200/>"
Or enter url in your browser
jsx
http://use.your.ip:9200/
You should see a response in JSON format, similar to the one below:
json
{
"name" : "your-node-name",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "cluster-uuid",
"version" : {
"number" : "7.x.x",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "build-hash",
"build_date" : "build-date",
"build_snapshot" : false,
"lucene_version" : "lucene-version",
"minimum_wire_compatibility_version" : "minimum-wire-version",
"minimum_index_compatibility_version" : "minimum-index-version"
},
"tagline" : "You Know, for Search"
}
Add a document to the new index test-index
:
curl -X POST "<http://localhost:9200/test-index/_doc/1>" -H 'Content-Type: application/json' -d'
{
"title": "Test Document",
"content": "This is a test document for ElasticSearch."
}'
Check if the document has been added correctly:
curl -X GET "<http://localhost:9200/test-index/_doc/1>"
You should see a response similar to the one below:
json
{
"_index": "test-index",
"_type": "_doc",
"_id": "1",
"_version": 1,
"_seq_no": 0,
"_primary_term": 1,
"found": true,
"_source": {
"title": "Test Document",
"content": "This is a test document for ElasticSearch."
}
}
Now search the test-index
for documents containing the word "test":
curl -X GET "<http://localhost:9200/test-index/_search>" -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"content": "test"
}
}
}'
You should see a response containing the document you just added:
json
{
"took": 30,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 0.2876821,
"hits": [
{
"_index": "test-index",
"_type": "_doc",
"_id": "1",
"_score": 0.2876821,
"_source": {
"title": "Test Document",
"content": "This is a test document for ElasticSearch."
}
}
]
}
}
You may want to configure your firewall, such as ufw
(Uncomplicated Firewall), to allow access only from your server's IP address. This means that only your server can access the necessary resources, and all other IP addresses will be blocked.
Report an application with malicious intent or harmful content.