Develop a tool that allows searching for a keyword in a set of +11,800 text files.
- Coverage of unit tests.
- Versioned code.
- Documentation to execute the code tool.
- The keyword search doesn't have a logical order.
- When a keyword is composed, the search criteria must be
AND
. - Process executed up to 1ms.
- The set of files can be pre-processed.
The developed tool has a structure to be executed and the allowed commands are described below:
Option | First Argument | Second Argument | Example | Consider |
---|---|---|---|---|
upload | index-name | path | upload my-index "./data" | the second argument must be contained in double quotes |
search | index-name | keyword | search my-index "walt disney" | the index-name must be the same that was used to upload the files |
native-search | index-name | keyword | native-search my-index "julian" | the index-name must be the same that was used to upload the files |
Run the docker-compose.yml
file with the command:
docker-compose up -d
We can now access ElasticSearch and Kibana instances at http://localhost:9200
and http://localhost:5601
respectively.
In case you don't have Docker installed, use this tutorial.
Populate the ElasticSearch instance with information from the text files found in the ./data
.
This process can be executed through the tool with the command:
java -jar bulksearch-app.jar upload <index-name> "./data"
Don't forget to remove the '<>' characters and change to the correct index.
You have two options to perform a search:
Run the next command to search with Elasticsearch Java API Client
java -jar bulksearch-app.jar search <index-name> "walt disney"
Run the next command to search with Rest native request
java -jar bulksearch-app.jar native-search <index-name> "walt disney"
The result for both queries will have the same result, the only difference is the response speed.
Result with search
option
Result with native-search
option
Technology | Using |
---|---|
Build application | |
Run commands | |
Prepare environment | |
Index data |
Ejecuta vĂa comando las pruebas unitarias con el siguiente comando:
> cd ./unit-test
> java -cp "junit-4.13.2.jar;." org.junit.runner.JUnitCore <ClassNameToTest>
get /index-name/_search
{
"_source": ["field-to-search"],
"query": {
"match": {
"content": {
"query": "words keys",
"operator": "and"
}
}
},"sort": [
{
"title": {
"order": "asc"
}
}
]
}