-
-
Save anonymous/78e12092e648e96c20f0 to your computer and use it in GitHub Desktop.
ElasticSearch Script to mimic Real Time Search. However, periodically it doesn't return any search results after waiting even an extra amount of time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "delete the index" | |
curl -XDELETE 'http://localhost:9200/gist/' | |
echo | |
echo | |
echo "create the index" | |
curl -XPUT 'http://localhost:9200/gist/' -d '{ | |
"settings" : { | |
"number_of_shards": 9, | |
"number_of_replicas": 2, | |
"refresh_interval": "500ms", | |
"auto_expand_replicas": "false" | |
} | |
,"mappings": { | |
"_default_": { | |
"properties": { | |
"ent": { | |
"dynamic": false, | |
"enabled": true, | |
"include_in_all": false, | |
"path": "full", | |
"type": "object", | |
"properties": { | |
"username": { | |
"dynamic": false, | |
"enabled": true, | |
"include_in_all": false, | |
"path": "full", | |
"properties": { | |
"_value": { | |
"type": "multi_field", | |
"fields": {"_value": { | |
"include_in_all": false, | |
"index": "not_analyzed", | |
"store": "yes", | |
"type": "string" | |
}} | |
}, | |
"_meta": { | |
"dynamic": true, | |
"type": "object" | |
} | |
}, | |
"type": "object" | |
} | |
} | |
} | |
} | |
} | |
} | |
}' | |
echo | |
echo | |
echo | |
echo | |
echo "Attempt to simulate real-time search for data loaded" | |
echo "1. Load the record" | |
echo "2. Mimic real-time search by sleeping for the refresh interval" | |
echo "3. Expect to search and obtain record" | |
echo '==================================' | |
echo | |
echo "load and search for record 1" | |
echo '==================================' | |
echo | |
curl -s -XPUT 'http://localhost:9200/gist/all-data/1' -d '{ | |
"ent": { | |
"username": { | |
"_value": "record1" | |
} | |
} | |
}' | |
echo | |
echo | |
sleep 5s | |
curl -XPOST 'http://localhost:9200/gist/all-data/_search' -d '{ | |
"size": 1, | |
"query": { | |
"term": { | |
"ent.username._value": "record1" | |
} | |
} | |
}' | |
echo | |
echo | |
curl -XPOST 'http://localhost:9200/gist/all-data/_search' -d '{ | |
"size": 1, | |
"query": { | |
"term": { | |
"ent.username._value": "record1" | |
} | |
} | |
}' | |
echo | |
echo | |
echo "load and search for record 2" | |
echo '==================================' | |
echo | |
curl -s -XPUT 'http://localhost:9200/gist/all-data/2' -d '{ | |
"ent": { | |
"username": { | |
"_value": "record2" | |
} | |
} | |
}' | |
echo | |
echo | |
sleep 5s | |
curl -XPOST 'http://localhost:9200/gist/all-data/_search' -d '{ | |
"size": 1, | |
"query": { | |
"term": { | |
"ent.username._value": "record2" | |
} | |
} | |
}' | |
echo | |
echo | |
curl -XPOST 'http://localhost:9200/gist/all-data/_search' -d '{ | |
"size": 1, | |
"query": { | |
"term": { | |
"ent.username._value": "record2" | |
} | |
} | |
}' | |
echo | |
echo | |
echo "load and search for record 3" | |
echo '==================================' | |
echo | |
curl -s -XPUT 'http://localhost:9200/gist/all-data/3' -d '{ | |
"ent": { | |
"username": { | |
"_value": "record3" | |
} | |
} | |
}' | |
echo | |
echo | |
echo "Manually Refresh this time" | |
echo | |
curl -XPOST 'http://localhost:9200/gist/_refresh' | |
echo | |
echo | |
curl -XPOST 'http://localhost:9200/gist/all-data/_search' -d '{ | |
"size": 1, | |
"query": { | |
"term": { | |
"ent.username._value": "record3" | |
} | |
} | |
}' | |
echo | |
echo | |
curl -XPOST 'http://localhost:9200/gist/all-data/_search' -d '{ | |
"size": 1, | |
"query": { | |
"term": { | |
"ent.username._value": "record3" | |
} | |
} | |
}' | |
echo | |
echo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment