I used Apache Solr to persist the data about Indian towns. Docker is used for setting up Solr. We also used Spring Boot to develop simple REST application which access Solr & expose the data via endpoints
Indian town details are collected from Internet. Hence, I don't stand for authenticity of the information. I have kept the source file I used for indexing Solr (in CSV format) under resource directory.
You can use find them here - Indian Towns Details in CSV
- Pull or download code from this repo
- Install Docker
- Once installed, start the Docker application in your system
- Once started, run the following commands
> mvn clean package
> docker-compose up --build
Thats it !!!
You can verify the success of setup by visiting http://localhost:8983/solr in your browser & selecting the IndianTowns core
http://localhost:8080/india/town/all
http://localhost:8080/india/town/paged/search?page=10&size=0&district=porbandar&state=gujarat
http://localhost:8080/india/town/paged/search?page=10&size=0&state=gujarat
http://localhost:8080/india/town/search?page=10&size=0&district=porbandar&state=gujarat
http://localhost:8080/india/town/search?page=10&size=0&state=gujarat
http://localhost:8080/india/town/search?state=assam&district=Nalbari
[
{
"category":"M.B",
"state":"Assam",
"district":"Nalbari",
"town_name":"Nalbari"
},
{
"category":"M.B",
"state":"Assam",
"district":"Nalbari",
"town_name":"Nalbari"
},
{
"category":"T.C",
"state":"Assam",
"district":"Nalbari",
"town_name":"Tihu"
}
]
http://localhost:8080/india/town/paged/search?page=10&size=0&state=gujarat
{
"content":[
{
"category":"M.B",
"state":"Assam",
"district":"Nalbari",
"town_name":"Nalbari"
},
{
"category":"M.B",
"state":"Assam",
"district":"Nalbari",
"town_name":"Nalbari"
},
{
"category":"T.C",
"state":"Assam",
"district":"Nalbari",
"town_name":"Tihu"
}
],
"pageable":{
"sort":{
"sorted":false,
"unsorted":true,
"empty":true
},
"offset":0,
"pageSize":20,
"pageNumber":0,
"unpaged":false,
"paged":true
},
"facetResultPages":[
],
"facetQueryResult":{
"content":[
],
"pageable":"INSTANCE",
"totalPages":1,
"totalElements":0,
"last":true,
"size":0,
"numberOfElements":0,
"first":true,
"number":0,
"sort":{
"sorted":false,
"unsorted":true,
"empty":true
},
"empty":true
},
"highlighted":[
],
"maxScore":null,
"fieldStatsResults":{
},
"suggestions":[
],
"facetFields":[
],
"facetPivotFields":[
],
"allFacets":[
null
],
"alternatives":[
],
"totalPages":1,
"totalElements":3,
"size":20,
"numberOfElements":3,
"first":true,
"number":0,
"sort":{
"sorted":false,
"unsorted":true,
"empty":true
},
"last":true,
"empty":false
}