Code Monkey home page Code Monkey logo

spring-data-solr-with-grails3-and-docker's Introduction

How to use spring-data-solr with grails-3.3.2 and solr in docker for development purpose

1. Include Spring Data Solr lib in gradle dependencies in build.gradle file
dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-solr', version: '1.5.9.RELEASE'
}
2. Write 2 files for docker solr configuration like below
1. spring-data-solr-with-grails3-and-docker/grails-app/conf/docker/solr.yml
2. spring-data-solr-with-grails3-and-docker/src/main/java/spring/style/config/SolrConfiguration.java
3. Write a SolrCrudRepository class and inject like below
1. spring-data-solr-with-grails3-and-docker/src/main/java/spring/style/repository/search/BlogSearchRepository.java
2. beans = {
       springBlogService(spring.style.service.SpringBlogService)
   }
4. Now look on below 2 Controller and Service
1. Controller :: ExploreController.groovy, Service :: GrailsBlogService.groovy 
2. Run grails app as it is and hit url [ http://localhost:8080/explore/index ] 
3. After that browse [ http://localhost:8983/solr/#/blogs/query ] 
4. Now you will see your data saved in solr server as json 
5. (^_^) Before run grails app please follow point (5 _ below) to create solr blogs collection 
5. Using Docker to simplify development (optional)

You can use Docker to improve your grails-with-solr development experience. A number of docker-compose configuration are available in the [ grails-app/conf/docker/ ] folder to launch required third party services. For example, to start a solr in a docker container, run: below command from the project root.

docker-compose -f grails-app/conf/docker/solr.yml up -d

or

docker-compose -f grails-app/conf/docker/solr.yml up

To stop it and remove the container, run:

docker-compose -f grails-app/conf/docker/solr.yml up down

After running the solr successfully, we have to create/delete solr collection using below command from any location of terminal.

Create Collection [ grailscol, blogs ] in solr(at docker)

docker exec -it --user=solr grails-solr bin/solr create_core -c grailscol
docker exec -it --user=solr grails-solr bin/solr create_core -c blogs

Delete Collection [ grailscol, blogs ] from solr(at docker)

docker exec -it --user=solr grails-solr bin/solr delete -c grailscol
docker exec -it --user=solr grails-solr bin/solr delete -c blogs

-- End

spring-data-solr-with-grails3-and-docker's People

Contributors

javagrails avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.