{"id":16485192,"url":"https://github.com/antoniofalcaojr/solrdotnetsample","last_synced_at":"2025-08-02T12:34:39.536Z","repository":{"id":37099352,"uuid":"263196895","full_name":"AntonioFalcaoJr/SolrDotnetSample","owner":"AntonioFalcaoJr","description":"Quick and simple use of Solr with dotnet core","archived":false,"fork":false,"pushed_at":"2023-02-15T08:58:35.000Z","size":315,"stargazers_count":3,"open_issues_count":10,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-13T15:43:56.172Z","etag":null,"topics":["aspnet","automapper","docker","dotnet","efcore","solr","solrnet","sqlite"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AntonioFalcaoJr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-12T01:06:19.000Z","updated_at":"2024-12-06T20:55:02.000Z","dependencies_parsed_at":"2024-10-28T21:16:40.668Z","dependency_job_id":null,"html_url":"https://github.com/AntonioFalcaoJr/SolrDotnetSample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AntonioFalcaoJr/SolrDotnetSample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonioFalcaoJr%2FSolrDotnetSample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonioFalcaoJr%2FSolrDotnetSample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonioFalcaoJr%2FSolrDotnetSample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonioFalcaoJr%2FSolrDotnetSample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AntonioFalcaoJr","download_url":"https://codeload.github.com/AntonioFalcaoJr/SolrDotnetSample/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonioFalcaoJr%2FSolrDotnetSample/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268389604,"owners_count":24242851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnet","automapper","docker","dotnet","efcore","solr","solrnet","sqlite"],"created_at":"2024-10-11T13:24:32.398Z","updated_at":"2025-08-02T12:34:39.489Z","avatar_url":"https://github.com/AntonioFalcaoJr.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample with .NET Core and SolrNet\n[![CodeFactor](https://www.codefactor.io/repository/github/antoniofalcao/solrdotnetsample/badge)](https://www.codefactor.io/repository/github/antoniofalcao/solrdotnetsample)\n[![.NET Core](https://github.com/AntonioFalcao/SolrDotnetSample/workflows/.NET%20Core/badge.svg?branch=master)](https://github.com/AntonioFalcao/SolrDotnetSample/actions?query=workflow%3A%22.NET+Core%22)\n[![Console App - Docker Image CI](https://github.com/AntonioFalcao/SolrDotnetSample/workflows/Console%20App%20-%20Docker%20Image%20CI/badge.svg?branch=master)](https://github.com/AntonioFalcao/SolrDotnetSample/actions?query=workflow%3A%22Console+App+-+Docker+Image+CI%22)\n[![WebApi - Docker Image CI](https://github.com/AntonioFalcao/SolrDotnetSample/workflows/WebApi%20-%20Docker%20Image%20CI/badge.svg?branch=master)](https://github.com/AntonioFalcao/SolrDotnetSample/actions?query=workflow%3A%22WebApi+-+Docker+Image+CI%22)\n\nEste projeto tem como objetivo explorar o funcionamento do **SolrNet** no consumo do serviço de search engine **Solr** em projetos .**NET Core.**\n\n## Getting Started\n\nApós o clone do projeto e siga os passos descritos na etapa de [instalação](#installing). \n\n ```bash\n git clone https://github.com/AntonioFalcao/SolrDotnetSample.git\n ```\n\n### Prerequisites\n\nSe faz necessário ambiente com seguintes recursos:\n\n* [.NET Core SDK](https://dotnet.microsoft.com/download) - The framework used.\n\n\u003e To check this functionality:\n\n```bash\ndotnet --version\n```\n\u003e For more details\n```bash\ndotnet --info\n```\n* [Entity Framework Core .NET Command-line Tools](https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet/) - The ORM service used.\n\u003e To install:\n```bash\ndotnet tool install --global dotnet-ef\n```\n\u003e To check this functionality:\n```bash\ndotnet-ef --version\n```\n* [Docker](https://www.docker.com/) - The container platform used\n\u003e To check this functionality:\n```bash\ndocker --version\n```\n### Installing\n\nCom o uso de **containerização**, podemos provisionar de forma prática a infraestrutura necessária.\n\nInicialmente utilizaremos o serviço **Solr**, para atender a necessidade de **Search Engine**, através do compose [`./solr-compose`](./solr-compose.yml).\n\n```bash\ndocker-compose -f solr-compose.yml up -d\n```\n\nO índice padrão, referido como [Core](https://lucene.apache.org/solr/guide/6_6/solr-cores-and-solr-xml.html) pelo Solr está definido como `my_core` no `entrypoint`, assim como o mapeamento de porta padrão `8983:8983`:\n\n```yaml\n services: \n# comment for brevity\n    ports:\n      - \"8983:8983\"\n    entrypoint:\n      - solr-precreate\n      - my_core\n# comment for brevity\n```\n#### Definindo Fields\n\nA definição dos [Fields](https://lucene.apache.org/solr/guide/6_6/field-type-definitions-and-properties.html#field-type-definitions-and-properties) no Solr é um passo essencial, para garantir que o dado terá a mesma representação desejada pelo modelo.\n\nExistem dois caminhos para isso, um deles é definir os detalhes dos fields no [schema.xml](https://lucene.apache.org/solr/guide/6_6/field-type-definitions-and-properties.html#FieldTypeDefinitionsandProperties-FieldTypeDefinitionsinschema.xml), a outra forma é realizando chamadas direta à API do serviço. Para segunda alternativa, existe o arquivo [solr-add-fields.http](./solr-add-fields.http) disponível no projeto:\n\n```http request\nPOST http://localhost:8983/solr/my_core/schema\nContent-Type: application/json\n\n{\n   \"add-field\":{\n      \"name\":\"Description\",\n      \"type\":\"string\",\n      \"stored\":true\n      },\n   \"add-field\":{\n      \"name\":\"Title\",\n      \"type\":\"string\",\n      \"stored\":true\n      },\n}\n\n### comment for brevity\n```\n#### Semeando dados no Solr\n\nUma vez provisionado o ambiente e configurado os fields, podemos semear dados através dos passos:\n\n 1.  Aplicar migrations do EF Core, que já se encarregará do Seed para o DB relacional.\n \u003e Nesta etapa irá ocorrer a semeadura de dados para o DB relacional. \n```bash\ndotnet ef database update -s ./src/SolrDotnetSample.WebApi/ -p ./src/SolrDotnetSample.Repositories/\n```\n 2. Executar aplicação console e selecionar opção de semeadura para o Solr.\n\u003e Duas opções estarão disponíveis, sendo: \n\u003e1. Gerar novos dados.\n\u003e2. Migrar dados do relacional. \n```bash\ndocker build -t seed -f ./consoleApp.Dockerfile . \u0026\u0026 docker run -it seed\n```\n## Running the tests\n\n#### Automated tests\nOs testes unitários e de integração podem ser executados com o respectivo comando:\n```bash\ndotnet test\n```\n#### Functional tests\nPara executarmos testes de forma funcional, devemos inicialmente executar o projeto para disponibilizar o serviço Web. \n\n```bash\ndocker build -t webapi -f ./webApi.Dockerfile . \u0026\u0026 docker run -p 5000:5000 webapi \n```\n\n\u003e O roteamento segue o padrão `http://hostname:port/api/v{version}/controller`\n\nPara realizar chamadas, pode estar utilizando o arquivo [./basic-api-call.http](./basic-api-call.http) através da extensão [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client), por exemplo:.\n\n\u003e `/api/v1/...` utiliza o banco de dados relacional.     \n\u003e `/api/v2/...` utiliza o Solr\n\n```http request\n### V1 - Relational DB\nGET http://localhost:5000/api/v1/posts\n\n### V2 - NoSql DB\nGET http://localhost:5000/api/v2/posts\n\n### V1 - Relational DB\nPOST http://localhost:5000/api/v1/posts\nContent-Type: application/json\n\n{\n  \"Description\": \"Description\",\n  \"ExpiryDate\": \"2020-01-01\",\n  \"IsActive\": true,\n  \"IsSold\": true,\n  \"PostDate\": \"2020-01-01\",\n  \"Price\": 0,\n  \"Title\": \"Title\"\n}\n\n### comment for brevity\n```\n## Deployment\n\nDetalhes sobre esteira (CI/CD) disponíveis em [Project GitHub Actions](https://github.com/AntonioFalcao/SolrDotnetSample/actions)\n\n## Built With\n\n##### Microsoft Stack\n* [.NET Core](https://dotnet.microsoft.com/) - The base framework used\n* [ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/?view=aspnetcore-3.1) - The web framework used\n* [EF Core](https://docs.microsoft.com/en-us/ef/core/get-started/?tabs=netcore-cli) - ORM\n* [AutoMapper](https://automapper.org/) - Library for mapping objects\n\n##### Solr Stack\n* [Solr](https://www.google.com/url?sa=t\u0026rct=j\u0026q=\u0026esrc=s\u0026source=web\u0026cd=\u0026cad=rja\u0026uact=8\u0026ved=2ahUKEwiT8fiYgdDpAhVMILkGHRapBdwQFjAAegQICBAC\u0026url=https%3A%2F%2Flucene.apache.org%2Fsolr%2F\u0026usg=AOvVaw220ce7CtImnLrhaQpO1SO2) - Search Engine used.\n* [SolrNet](https://github.com/SolrNet/SolrNet/) - Apache Solr client for .NET\n\n## Contributing\n\nAvailable soon! \n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/AntonioFalcao/SolrDotnetSample/tags). \n\n## Authors\n\n* **Antônio Falcão** - [GitHub](https://github.com/AntonioFalcao)\n\n\u003e See also the list of [contributors](https://github.com/AntonioFalcao/SolrDotnetSample/graphs/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Acknowledgments\n\n* Nothing more, for now.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniofalcaojr%2Fsolrdotnetsample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantoniofalcaojr%2Fsolrdotnetsample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniofalcaojr%2Fsolrdotnetsample/lists"}