├── .gitignore ├── CommonAssemblyInfo.cs ├── GitVersionConfig.yaml ├── LICENSE ├── README.md ├── Umbraco.Elasticsearch.sln ├── appveyor.yml ├── build.cake ├── build.ps1 ├── cake.config ├── lib └── icons │ └── umbraco-es.png ├── samples ├── Umbraco.Elasticsearch.Samplev73 │ ├── App_Browsers │ │ ├── Form.browser │ │ └── w3cvalidator.browser │ ├── App_Data │ │ └── packages │ │ │ └── installed │ │ │ └── installedPackages.config │ ├── App_Plugins │ │ └── umbElasticsearch │ │ │ ├── package.manifest │ │ │ ├── umbElasticsearch.controller.js │ │ │ ├── umbElasticsearch.css │ │ │ ├── umbElasticsearch.html │ │ │ └── umbElasticsearch.resource.js │ ├── App_Start │ │ └── SearchifyMvcConfig.cs │ ├── Config │ │ ├── 404handlers.config │ │ ├── BaseRestExtensions.config │ │ ├── ClientDependency.config │ │ ├── Dashboard.config │ │ ├── EmbeddedMedia.config │ │ ├── ExamineIndex.config │ │ ├── ExamineSettings.config │ │ ├── FileSystemProviders.config │ │ ├── Lang │ │ │ ├── cs-CZ.user.xml │ │ │ ├── da-DK.user.xml │ │ │ ├── de-DE.user.xml │ │ │ ├── en-GB.user.xml │ │ │ ├── en-US.user.xml │ │ │ ├── es-ES.user.xml │ │ │ ├── fr-FR.user.xml │ │ │ ├── he-IL.user.xml │ │ │ ├── it-IT.user.xml │ │ │ ├── ja-JP.user.xml │ │ │ ├── ko-KR.user.xml │ │ │ ├── nb-NO.user.xml │ │ │ ├── nl-NL.user.xml │ │ │ ├── pl-PL.user.xml │ │ │ ├── pt-BR.user.xml │ │ │ ├── ru-RU.user.xml │ │ │ ├── sv-SE.user.xml │ │ │ └── zh-CN.user.xml │ │ ├── UrlRewriting.config │ │ ├── applications.config │ │ ├── feedProxy.config │ │ ├── grid.editors.config.js │ │ ├── log4net.config │ │ ├── metablogConfig.config │ │ ├── scripting.config │ │ ├── splashes │ │ │ ├── booting.aspx │ │ │ └── noNodes.aspx │ │ ├── tinyMceConfig.config │ │ ├── trees.config │ │ └── umbracoSettings.config │ ├── Features │ │ └── Search │ │ │ ├── Controllers │ │ │ └── DtSearchController.cs │ │ │ ├── Models │ │ │ └── SearchResultModel.cs │ │ │ ├── Queries │ │ │ ├── Article │ │ │ │ ├── ArticleDocument.cs │ │ │ │ ├── ArticleSearchParameters.cs │ │ │ │ ├── ArticleSearchQuery.cs │ │ │ │ └── ArticleSearchResult.cs │ │ │ ├── Image │ │ │ │ └── ImageDocument.cs │ │ │ └── UmbracoDocument.cs │ │ │ ├── Services │ │ │ ├── Article │ │ │ │ └── ArticleContentIndexService.cs │ │ │ └── Image │ │ │ │ └── ImageMediaIndexService.cs │ │ │ └── UmbracoElasticsearchStartup.cs │ ├── Global.asax │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Umbraco.Elasticsearch.Samplev73.csproj │ ├── Views │ │ ├── Article.cshtml │ │ ├── Articles.cshtml │ │ ├── DtSearch │ │ │ └── DtSearch.cshtml │ │ ├── Home.cshtml │ │ ├── Partials │ │ │ └── Grid │ │ │ │ ├── Bootstrap2.cshtml │ │ │ │ ├── Bootstrap3.cshtml │ │ │ │ └── Editors │ │ │ │ ├── Base.cshtml │ │ │ │ ├── Embed.cshtml │ │ │ │ ├── Macro.cshtml │ │ │ │ ├── Media.cshtml │ │ │ │ ├── Rte.cshtml │ │ │ │ └── Textstring.cshtml │ │ ├── Shared │ │ │ └── _SearchifyMvcParametersPartial.cshtml │ │ └── Web.config │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── default.aspx │ └── packages.config ├── Umbraco.Elasticsearch.Samplev74 │ ├── App_Browsers │ │ ├── Form.browser │ │ └── w3cvalidator.browser │ ├── App_Data │ │ ├── Umbraco.7z │ │ └── packages │ │ │ └── installed │ │ │ └── installedPackages.config │ ├── App_Plugins │ │ ├── ModelsBuilder │ │ │ ├── modelsbuilder.controller.js │ │ │ ├── modelsbuilder.htm │ │ │ ├── modelsbuilder.resource.js │ │ │ └── package.manifest │ │ └── umbElasticsearch │ │ │ ├── assets │ │ │ └── hourglass.svg │ │ │ ├── package.manifest │ │ │ ├── umbElasticsearch.controller.js │ │ │ ├── umbElasticsearch.css │ │ │ ├── umbElasticsearch.html │ │ │ └── umbElasticsearch.resource.js │ ├── App_Start │ │ └── SearchifyMvcConfig.cs │ ├── Config │ │ ├── 404handlers.config │ │ ├── BaseRestExtensions.config │ │ ├── ClientDependency.config │ │ ├── Dashboard.config │ │ ├── EmbeddedMedia.config │ │ ├── ExamineIndex.config │ │ ├── ExamineSettings.config │ │ ├── FileSystemProviders.config │ │ ├── Lang │ │ │ ├── cs-CZ.user.xml │ │ │ ├── da-DK.user.xml │ │ │ ├── de-DE.user.xml │ │ │ ├── en-GB.user.xml │ │ │ ├── en-US.user.xml │ │ │ ├── es-ES.user.xml │ │ │ ├── fr-FR.user.xml │ │ │ ├── he-IL.user.xml │ │ │ ├── it-IT.user.xml │ │ │ ├── ja-JP.user.xml │ │ │ ├── ko-KR.user.xml │ │ │ ├── nb-NO.user.xml │ │ │ ├── nl-NL.user.xml │ │ │ ├── pl-PL.user.xml │ │ │ ├── pt-BR.user.xml │ │ │ ├── ru-RU.user.xml │ │ │ ├── sv-SE.user.xml │ │ │ └── zh-CN.user.xml │ │ ├── UrlRewriting.config │ │ ├── applications.config │ │ ├── feedProxy.config │ │ ├── grid.editors.config.js │ │ ├── log4net.config │ │ ├── metablogConfig.config │ │ ├── scripting.config │ │ ├── splashes │ │ │ ├── booting.aspx │ │ │ └── noNodes.aspx │ │ ├── tinyMceConfig.config │ │ ├── trees.config │ │ └── umbracoSettings.config │ ├── Features │ │ └── Search │ │ │ ├── Controllers │ │ │ └── DtSearchController.cs │ │ │ ├── Models │ │ │ └── SearchResultModel.cs │ │ │ ├── Queries │ │ │ ├── Article │ │ │ │ ├── ArticleDocument.cs │ │ │ │ ├── ArticleSearchParameters.cs │ │ │ │ ├── ArticleSearchQuery.cs │ │ │ │ └── ArticleSearchResult.cs │ │ │ ├── Image │ │ │ │ └── ImageDocument.cs │ │ │ └── UmbracoDocument.cs │ │ │ ├── Services │ │ │ ├── Article │ │ │ │ └── ArticleContentIndexService.cs │ │ │ └── Image │ │ │ │ └── ImageMediaIndexService.cs │ │ │ └── UmbracoElasticsearchStartup.cs │ ├── Global.asax │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Umbraco.Elasticsearch.Samplev74.csproj │ ├── Views │ │ ├── DtSearch │ │ │ └── DtSearch.cshtml │ │ ├── Partials │ │ │ └── Grid │ │ │ │ ├── Bootstrap2.cshtml │ │ │ │ ├── Bootstrap3.cshtml │ │ │ │ └── Editors │ │ │ │ ├── Base.cshtml │ │ │ │ ├── Embed.cshtml │ │ │ │ ├── Macro.cshtml │ │ │ │ ├── Media.cshtml │ │ │ │ ├── Rte.cshtml │ │ │ │ └── Textstring.cshtml │ │ ├── Shared │ │ │ └── _SearchifyMvcParametersPartial.cshtml │ │ ├── Web.config │ │ ├── articles.cshtml │ │ ├── dtArticle.cshtml │ │ └── dtHome.cshtml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── default.aspx │ ├── media │ │ └── 1001 │ │ │ └── 0grkt8x.png │ └── packages.config └── Umbraco.Elasticsearch.Samplev75 │ ├── App_Browsers │ ├── Form.browser │ └── w3cvalidator.browser │ ├── App_Data │ ├── Models │ │ ├── all.generated.cs │ │ ├── models.generated.cs │ │ └── models.hash │ └── packages │ │ └── installed │ │ └── installedPackages.config │ ├── App_Plugins │ ├── ModelsBuilder │ │ ├── modelsbuilder.controller.js │ │ ├── modelsbuilder.htm │ │ ├── modelsbuilder.resource.js │ │ └── package.manifest │ └── umbElasticsearch │ │ ├── package.manifest │ │ ├── umbElasticsearch.controller.js │ │ ├── umbElasticsearch.css │ │ ├── umbElasticsearch.html │ │ ├── umbElasticsearch.resource.js │ │ └── updateIndexNode.html │ ├── App_Start │ └── SearchifyMvcConfig.cs │ ├── Config │ ├── 404handlers.config │ ├── BaseRestExtensions.config │ ├── ClientDependency.config │ ├── Dashboard.config │ ├── EmbeddedMedia.config │ ├── ExamineIndex.config │ ├── ExamineSettings.config │ ├── FileSystemProviders.config │ ├── Lang │ │ ├── cs-CZ.user.xml │ │ ├── da-DK.user.xml │ │ ├── de-DE.user.xml │ │ ├── en-GB.user.xml │ │ ├── en-US.user.xml │ │ ├── es-ES.user.xml │ │ ├── fr-FR.user.xml │ │ ├── he-IL.user.xml │ │ ├── it-IT.user.xml │ │ ├── ja-JP.user.xml │ │ ├── ko-KR.user.xml │ │ ├── nb-NO.user.xml │ │ ├── nl-NL.user.xml │ │ ├── pl-PL.user.xml │ │ ├── pt-BR.user.xml │ │ ├── ru-RU.user.xml │ │ ├── sv-SE.user.xml │ │ └── zh-CN.user.xml │ ├── UrlRewriting.config │ ├── applications.config │ ├── feedProxy.config │ ├── grid.editors.config.js │ ├── log4net.config │ ├── metablogConfig.config │ ├── scripting.config │ ├── splashes │ │ ├── booting.aspx │ │ └── noNodes.aspx │ ├── tinyMceConfig.config │ ├── trees.config │ └── umbracoSettings.config │ ├── Features │ └── Search │ │ ├── Controllers │ │ └── DtSearchController.cs │ │ ├── Models │ │ └── SearchResultModel.cs │ │ ├── Queries │ │ ├── Article │ │ │ ├── ArticleDocument.cs │ │ │ ├── ArticleSearchParameters.cs │ │ │ ├── ArticleSearchQuery.cs │ │ │ └── ArticleSearchResult.cs │ │ ├── Image │ │ │ └── ImageDocument.cs │ │ └── UmbracoDocument.cs │ │ ├── Services │ │ ├── Article │ │ │ └── ArticleContentIndexService.cs │ │ └── Image │ │ │ └── ImageMediaIndexService.cs │ │ └── UmbracoElasticsearchStartup.cs │ ├── Global.asax │ ├── Media │ ├── 1001 │ │ └── 0grkt8x.png │ ├── 1002 │ │ └── 0grkt8x.png │ ├── 1003 │ │ └── coordinator-clipart-wedding-hearts-clip-art2.jpg │ └── Web.config │ ├── Properties │ └── AssemblyInfo.cs │ ├── Umbraco.Elasticsearch.Samplev75.csproj │ ├── Views │ ├── Article.cshtml │ ├── Articles.cshtml │ ├── DtSearch │ │ └── DtSearch.cshtml │ ├── Home.cshtml │ ├── Partials │ │ └── Grid │ │ │ ├── Bootstrap2.cshtml │ │ │ ├── Bootstrap3.cshtml │ │ │ └── Editors │ │ │ ├── Base.cshtml │ │ │ ├── Embed.cshtml │ │ │ ├── Macro.cshtml │ │ │ ├── Media.cshtml │ │ │ ├── Rte.cshtml │ │ │ └── Textstring.cshtml │ ├── Shared │ │ └── _SearchifyMvcParametersPartial.cshtml │ ├── Web.config │ └── dtSearch.cshtml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── default.aspx │ └── packages.config ├── src ├── Umbraco.Elasticsearch.Core │ ├── BusyStateManager.cs │ ├── Config │ │ ├── DashboardHelper.cs │ │ ├── DefaultIndexNameResolver.cs │ │ ├── FromConfigSearchSettings.cs │ │ ├── ISearchIndexNameResolver.cs │ │ ├── ISearchSettings.cs │ │ ├── PluginVersionInfo.cs │ │ ├── SearchSettings.cs │ │ ├── SearchSettingsExtensions.cs │ │ └── UmbElasticsearchConstants.cs │ ├── Content │ │ ├── IContentIndexService.cs │ │ └── Impl │ │ │ ├── ContentIndexService.cs │ │ │ └── ContentIndexer.cs │ ├── EventHandlers │ │ ├── SearchApplicationEventHandler_Base.cs │ │ ├── SearchApplicationEventHandler_Configure.cs │ │ ├── SearchApplicationEventHandler_Content.cs │ │ └── SearchApplicationEventHandler_Media.cs │ ├── IElasticsearchIndexCreationStrategy.cs │ ├── IEntityIndexer.cs │ ├── IIndexManager.cs │ ├── IIndexService.cs │ ├── IUmbracoDocument.cs │ ├── Impl │ │ ├── ElasticsearchIndexCreationStrategy.cs │ │ ├── IndexManager.cs │ │ └── IndexService.cs │ ├── Media │ │ ├── IMediaIndexService.cs │ │ └── Impl │ │ │ ├── MediaIndexService.cs │ │ │ └── MediaIndexer.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Umbraco.Elasticsearch.Core.csproj │ ├── Umbraco.Elasticsearch.Core.nuspec │ ├── UmbracoSearchFactory.cs │ ├── Utils │ │ ├── ConfigurationManagerUtils.cs │ │ ├── ContentExtensions.cs │ │ └── EnumerableExtensions.cs │ ├── app.config │ └── packages.config └── Umbraco.Elasticsearch │ ├── Admin │ ├── Api │ │ └── UmbElasticsearchIndexingController.cs │ └── Events │ │ └── SearchApplicationInstallServerVarsEventHandler.cs │ ├── HealthChecks │ └── ElasticsearchHealthCheck.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Umbraco.Elasticsearch.csproj │ ├── Umbraco.Elasticsearch.nuspec │ ├── app.config │ ├── content │ ├── App_Plugins │ │ └── umbElasticsearch │ │ │ ├── package.manifest │ │ │ ├── umbElasticsearch.controller.js │ │ │ ├── umbElasticsearch.css │ │ │ ├── umbElasticsearch.html │ │ │ ├── umbElasticsearch.resource.js │ │ │ └── updateIndexNode.html │ ├── dashboard.config.install.xdt │ ├── dashboard.config.uninstall.xdt │ ├── web.config.install.xdt │ └── web.config.uninstall.xdt │ ├── packages.config │ └── readme.txt └── tools └── packages.config /.gitignore: -------------------------------------------------------------------------------- 1 | # Misc folders 2 | [Bb]in/ 3 | [Oo]bj/ 4 | [Pp]ackages/ 5 | 6 | # Build related 7 | /tools/ 8 | /VersionAssemblyInfo.cs 9 | /artifacts/ 10 | node_modules 11 | 12 | ## Ignore Visual Studio temporary files, build results, and 13 | ## files generated by popular Visual Studio add-ons. 14 | 15 | # User-specific files 16 | *.suo 17 | *.user 18 | *.sln.docstates 19 | *.sln.ide/ 20 | *.userprefs 21 | *.GhostDoc.xml 22 | .vs/ 23 | 24 | # Build results 25 | [Dd]ebug/ 26 | [Rr]elease/ 27 | x64/ 28 | *_i.c 29 | *_p.c 30 | *.ilk 31 | *.meta 32 | *.obj 33 | *.pch 34 | *.pdb 35 | *.pgc 36 | *.pgd 37 | *.rsp 38 | *.sbr 39 | *.tlb 40 | *.tli 41 | *.tlh 42 | *.tmp 43 | *.log 44 | *.vspscc 45 | *.vssscc 46 | .builds 47 | 48 | # Visual Studio profiler 49 | *.psess 50 | *.vsp 51 | *.vspx 52 | 53 | # ReSharper is a .NET coding add-in 54 | _ReSharper* 55 | 56 | # NCrunch 57 | *.ncrunch* 58 | .*crunch*.local.xml 59 | _NCrunch_* 60 | 61 | # Windows 62 | Thumbs.db 63 | 64 | # Umbraco 65 | # Ignore unimportant folders generated by Umbraco 66 | samples/**/App_Data/Logs/ 67 | samples/**/App_Data/[Pp]review/ 68 | samples/**/App_Data/TEMP/ 69 | samples/**/App_Data/NuGetBackup/ 70 | 71 | # Ignore Umbraco content cache file 72 | samples/**/App_Data/umbraco.config 73 | 74 | # Don't ignore Umbraco packages (VisualStudio.gitignore mistakes this for a NuGet packages folder) 75 | # Make sure to include details from VisualStudio.gitignore BEFORE this 76 | !samples/**/App_Data/[Pp]ackages/ 77 | !samples/**/[Uu]mbraco/[Dd]eveloper/[Pp]ackages 78 | !samples/**/App_Data/Models/ 79 | 80 | # ImageProcessor DiskCache 81 | samples/**/App_Data/cache/ 82 | 83 | samples/**/App_Data/Umbraco.sdf 84 | 85 | samples/**/Umbraco_Client/ 86 | samples/**/Umbraco/ 87 | -------------------------------------------------------------------------------- /CommonAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyCompany("Storm ID")] 5 | [assembly: AssemblyCopyright("Copyright 2009-2016 Storm ID Ltd. All rights reserved.")] 6 | [assembly: AssemblyProduct("Umbraco.Elasticsearch")] 7 | [assembly: ComVisible(false)] 8 | 9 | -------------------------------------------------------------------------------- /GitVersionConfig.yaml: -------------------------------------------------------------------------------- 1 | assembly-versioning-scheme: MajorMinorPatch 2 | mode: ContinuousDeployment 3 | branches: 4 | master: 5 | increment: Patch 6 | prevent-increment-of-merged-branch-version: true 7 | (pull|pull\-requests|pr)[/-]: 8 | tag: PullRequest 9 | increment: Inherit 10 | track-merge-target: true 11 | tag-number-pattern: '[/-](?\d+)[-/]' -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Phil Oyston 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Umbraco.Elasticsearch 2 | Integration of Elasticsearch (v5 only) as a search platform for Umbraco v7.5+ 3 | 4 | [![Build status](https://ci.appveyor.com/api/projects/status/y7trnlo257kgy9rl/branch/master?svg=true)](https://ci.appveyor.com/project/Philo/umbraco-elasticsearch/branch/master) 5 | 6 | [![NuGet](https://img.shields.io/nuget/v/Umbraco.Elasticsearch.svg?maxAge=2592000)](https://www.nuget.org/packages/Umbraco.Elasticsearch/) 7 | 8 | Umbraco.Elasticsearch is an Umbraco plugin designed to integrate your CMS with Elasticsearch. It is *not* designed to replace any built-in search features of Umbraco (Examine) and instead provides an independent point of search integration in which your CMS acts as a data source for your search index. 9 | 10 | Umbraco.Elasticsearch is *not* an _"install and forget"_ solution, to use it will be expected to have knowledge of the following: 11 | 12 | * Develop custom code and logic within your Umbraco CMS, Umbraco.Elasticsearch is a code centric library 13 | * How to extract node properties from Umbraco programmatically using ```IContent```, ```IMedia``` and the ```ServiceContext``` services 14 | * How to use the [NEST](https://nest.azurewebsites.net) Elasticsearch library to: 15 | * Define indexing document mappings via either the NEST attributes or the ```IElasticClient``` 16 | * Write search queries using the NEST fluent DSL within the [Nest-Searchify](https://github.com/stormid/Nest-Searchify) library wrapper 17 | 18 | Installing Umbraco.Elasticsearch does not instantly give you full-text search over your CMS content, you will need to review the [sample](https://github.com/Philo/Umbraco.Elasticsearch/tree/master/samples) projects or read the [documentation](https://github.com/Philo/Umbraco.Elasticsearch/wiki) to learn how to get up and running. 19 | 20 | Information on the latest release can be found within the github [releases](https://github.com/Philo/Umbraco.Elasticsearch/releases/latest). 21 | -------------------------------------------------------------------------------- /Umbraco.Elasticsearch.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26403.7 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Elasticsearch", "src\Umbraco.Elasticsearch\Umbraco.Elasticsearch.csproj", "{28C290DF-1357-4DE1-8947-B7B65017F766}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{324151CA-EC47-45E8-9B42-BDDC385BF2A6}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{2DB6DC6B-C2DF-4657-8DD4-903397EC522D}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Elasticsearch.Core", "src\Umbraco.Elasticsearch.Core\Umbraco.Elasticsearch.Core.csproj", "{03764FFB-42FC-4613-81D8-C1BF4F27C144}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Elasticsearch.Samplev75", "samples\Umbraco.Elasticsearch.Samplev75\Umbraco.Elasticsearch.Samplev75.csproj", "{36A41D27-5851-47A3-8D51-C961BF1A1F45}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {28C290DF-1357-4DE1-8947-B7B65017F766}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {28C290DF-1357-4DE1-8947-B7B65017F766}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {28C290DF-1357-4DE1-8947-B7B65017F766}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {28C290DF-1357-4DE1-8947-B7B65017F766}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {03764FFB-42FC-4613-81D8-C1BF4F27C144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {03764FFB-42FC-4613-81D8-C1BF4F27C144}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {03764FFB-42FC-4613-81D8-C1BF4F27C144}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {03764FFB-42FC-4613-81D8-C1BF4F27C144}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {36A41D27-5851-47A3-8D51-C961BF1A1F45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {36A41D27-5851-47A3-8D51-C961BF1A1F45}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {36A41D27-5851-47A3-8D51-C961BF1A1F45}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {36A41D27-5851-47A3-8D51-C961BF1A1F45}.Release|Any CPU.Build.0 = Release|Any CPU 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(NestedProjects) = preSolution 39 | {28C290DF-1357-4DE1-8947-B7B65017F766} = {324151CA-EC47-45E8-9B42-BDDC385BF2A6} 40 | {03764FFB-42FC-4613-81D8-C1BF4F27C144} = {324151CA-EC47-45E8-9B42-BDDC385BF2A6} 41 | {36A41D27-5851-47A3-8D51-C961BF1A1F45} = {2DB6DC6B-C2DF-4657-8DD4-903397EC522D} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | os: Visual Studio 2015 3 | skip_branch_with_pr: true 4 | nuget: 5 | disable_publish_on_pr: true 6 | init: 7 | - cmd: git config --global core.autocrlf true 8 | cache: 9 | - packages -> src\**\packages.config 10 | - tools -> tools\packages.config 11 | build_script: 12 | - ps: .\build.ps1 -Target "Default" -Verbosity "Normal" -Configuration "Release" 13 | test: off 14 | artifacts: 15 | - path: artifacts\*.nupkg 16 | deploy: 17 | - provider: NuGet 18 | server: https://www.myget.org/F/umb/api/v2/package 19 | api_key: 20 | secure: uBbnpdXGOXoRoYN/p49RmU2xP+1KOAmw5tMMGL2Ui/W1MvkUwC++4oLw8kJgNYDn 21 | skip_symbols: true -------------------------------------------------------------------------------- /cake.config: -------------------------------------------------------------------------------- 1 | ; This is the default configuration file for Cake. 2 | ; This file was downloaded from https://github.com/cake-build/resources 3 | 4 | [Roslyn] 5 | NuGetSource=https://packages.nuget.org/api/v2 6 | 7 | [Paths] 8 | Tools=./tools 9 | Addins=./tools/Addins -------------------------------------------------------------------------------- /lib/icons/umbraco-es.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/ffd8b0e454f9fa81b9d1f0bf3016b772b9257a22/lib/icons/umbraco-es.png -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/App_Browsers/Form.browser: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/App_Browsers/w3cvalidator.browser: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/App_Data/packages/installed/installedPackages.config: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/App_Plugins/umbElasticsearch/package.manifest: -------------------------------------------------------------------------------- 1 | { 2 | javascript: [ 3 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.resource.js", 4 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.controller.js" 5 | ], 6 | "css": [ 7 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.css" 8 | ] 9 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/App_Plugins/umbElasticsearch/umbElasticsearch.css: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/App_Plugins/umbElasticsearch/umbElasticsearch.resource.js: -------------------------------------------------------------------------------- 1 | /*global Umbraco */ 2 | angular.module("umbraco.resources") 3 | .factory("umbElasticsearchResource", function ($http, umbRequestHelper) { 4 | var apiUrl = function (method) { 5 | return umbRequestHelper.getApiUrl("umbElasticsearchApiUrl", method); 6 | } 7 | 8 | return { 9 | getVersionNumber: function () { 10 | return $http.get(apiUrl("SearchVersionInfo")).then(function(data) { 11 | return data.data.version; 12 | }); 13 | }, 14 | getPluginVersionInfo: function () { 15 | return $http.get(apiUrl("PluginVersionInfo")).then(function (data) { 16 | return data.data; 17 | }); 18 | }, 19 | getIndicesInfo: function () { 20 | return umbRequestHelper.resourcePromise($http.get(apiUrl("IndicesInfo"))); 21 | }, 22 | getIndexInfo: function (indexName) { 23 | return umbRequestHelper.resourcePromise($http.post(apiUrl("GetIndexInfo"), '"' + indexName + '"')); 24 | }, 25 | rebuildContentIndex: function (indexName) { 26 | return umbRequestHelper.resourcePromise($http.post(apiUrl("RebuildContentIndex"), '"' + indexName + '"')); 27 | }, 28 | rebuildMediaIndex: function (indexName) { 29 | return umbRequestHelper.resourcePromise($http.post(apiUrl("RebuildMediaIndex"), '"' + indexName + '"')); 30 | }, 31 | createIndex: function () { 32 | return umbRequestHelper.resourcePromise($http.post(apiUrl("CreateIndex"))); 33 | }, 34 | deleteIndexByName: function (indexName) { 35 | return umbRequestHelper.resourcePromise($http.post(apiUrl("DeleteIndexByName"), '"' + indexName + '"')); 36 | }, 37 | activateIndexByName: function (indexName) { 38 | return umbRequestHelper.resourcePromise($http.post(apiUrl("ActivateIndexByName"), '"' + indexName + '"')); 39 | }, 40 | getContentIndexServices: function () { 41 | return umbRequestHelper.resourcePromise($http.get(apiUrl("ContentIndexServicesList"))); 42 | }, 43 | getMediaIndexServices: function () { 44 | return umbRequestHelper.resourcePromise($http.get(apiUrl("MediaIndexServicesList"))); 45 | }, 46 | getSettings: function () { 47 | return Umbraco.Sys.ServerVariables.umbracoPlugins.umbElasticsearch; 48 | }, 49 | ping: function () { 50 | return $http.get(apiUrl("Ping")).then(function (response) { 51 | return response.data.active !== null && response.data.active === true; 52 | }); 53 | }, 54 | isBusy: function () { 55 | return umbRequestHelper.resourcePromise($http.get(apiUrl("IsBusy"))); 56 | } 57 | }; 58 | }); -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/App_Start/SearchifyMvcConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using Nest.Searchify.Mvc.Config; 3 | using Nest.Searchify.Queries; 4 | 5 | namespace Umbraco.Elasticsearch.Samplev73 6 | { 7 | public static class SearchifyMvcConfig 8 | { 9 | public static void Configure(HttpApplication application) 10 | { 11 | SearchifyMvcConfiguration.Configure(c => c 12 | .ParameterBinding(p => p 13 | .FromThisAssembly() 14 | .FromAssemblyContaining() 15 | )); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/404handlers.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/BaseRestExtensions.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 13 | 19 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Dashboard.config: -------------------------------------------------------------------------------- 1 |  2 | 3 |
4 | 5 | settings 6 | 7 | 8 | 9 | views/dashboard/settings/settingsdashboardintro.html 10 | 11 | 12 |
13 |
14 | 15 | forms 16 | 17 | 18 | 19 | views/dashboard/forms/formsdashboardintro.html 20 | 21 | 22 |
23 |
24 | 25 | developer 26 | 27 | 28 | 29 | views/dashboard/developer/developerdashboardvideos.html 30 | 31 | 32 | 33 | 34 | views/dashboard/developer/xmldataintegrityreport.html 35 | 36 | 37 | 38 | 39 | views/dashboard/developer/examinemanagement.html 40 | 41 | 42 |
43 |
44 | 45 | media 46 | 47 | 48 | 49 | views/dashboard/media/mediafolderbrowser.html 50 | 51 | 52 |
53 |
54 | 55 | translator 56 | 57 | 58 | content 59 | 60 | 61 | 62 | admin 63 | 64 | 65 | views/dashboard/default/startupdashboardintro.html 66 | 67 | 68 | 69 | 70 | views/dashboard/ChangePassword.html 71 | 72 | 73 |
74 |
75 | 76 | member 77 | 78 | 79 | 80 | views/dashboard/members/membersdashboardvideos.html 81 | 82 | 83 |
84 |
85 | 86 | developer 87 | 88 | 89 | 90 | admin 91 | 92 | /App_Plugins/umbElasticsearch/umbElasticsearch.html 93 | 94 |
95 |
-------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/ExamineIndex.config: -------------------------------------------------------------------------------- 1 |  2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/ExamineSettings.config: -------------------------------------------------------------------------------- 1 |  2 | 9 | 10 | 11 | 12 | 16 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/FileSystemProviders.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/cs-CZ.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/da-DK.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/de-DE.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/en-GB.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/en-US.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/es-ES.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/fr-FR.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/he-IL.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/it-IT.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/ja-JP.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/ko-KR.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/nb-NO.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/nl-NL.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/pl-PL.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/pt-BR.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/ru-RU.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/sv-SE.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/Lang/zh-CN.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/UrlRewriting.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/applications.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/feedProxy.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/grid.editors.config.js: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Rich text editor", 4 | "alias": "rte", 5 | "view": "rte", 6 | "icon": "icon-article" 7 | }, 8 | { 9 | "name": "Image", 10 | "alias": "media", 11 | "view": "media", 12 | "icon": "icon-picture" 13 | }, 14 | { 15 | "name": "Macro", 16 | "alias": "macro", 17 | "view": "macro", 18 | "icon": "icon-settings-alt" 19 | }, 20 | { 21 | "name": "Embed", 22 | "alias": "embed", 23 | "view": "embed", 24 | "icon": "icon-movie-alt" 25 | }, 26 | { 27 | "name": "Headline", 28 | "alias": "headline", 29 | "view": "textstring", 30 | "icon": "icon-coin", 31 | "config": { 32 | "style": "font-size: 36px; line-height: 45px; font-weight: bold", 33 | "markup": "

#value#

" 34 | } 35 | }, 36 | { 37 | "name": "Quote", 38 | "alias": "quote", 39 | "view": "textstring", 40 | "icon": "icon-quote", 41 | "config": { 42 | "style": "border-left: 3px solid #ccc; padding: 10px; color: #ccc; font-family: serif; font-variant: italic; font-size: 18px", 43 | "markup": "
#value#
" 44 | } 45 | } 46 | ] -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/log4net.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/metablogConfig.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/scripting.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/splashes/booting.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %> 2 | 3 | <% 4 | // NH: Adds this inline check to avoid a simple codebehind file in the legacy project! 5 | if (Request["url"].ToLower().Contains("booting.aspx") || !umbraco.cms.helpers.url.ValidateProxyUrl(Request["url"], Request.Url.AbsoluteUri)) 6 | { 7 | throw new ArgumentException("Can't redirect to the requested url - it's not local or an approved proxy url", 8 | "url"); 9 | } 10 | %> 11 | 12 | 13 | 14 | The website is restarting 15 | "> 16 | 17 | 18 |

The website is restarting

19 |

Please wait for 10s while we prepare to serve the page you have requested...

20 | 21 |

22 | You can modify the design of this page by editing /config/splashes/booting.aspx 23 |

24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Config/splashes/noNodes.aspx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/ffd8b0e454f9fa81b9d1f0bf3016b772b9257a22/samples/Umbraco.Elasticsearch.Samplev73/Config/splashes/noNodes.aspx -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/Controllers/DtSearchController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using Nest.Queryify.Extensions; 3 | using Umbraco.Elasticsearch.Core; 4 | using Umbraco.Elasticsearch.Samplev73.Features.Search.Models; 5 | using Umbraco.Elasticsearch.Samplev73.Features.Search.Queries.Article; 6 | using Umbraco.Web.Models; 7 | using Umbraco.Web.Mvc; 8 | 9 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search.Controllers 10 | { 11 | public class DtSearchController : RenderMvcController 12 | { 13 | [NonAction] 14 | public override ActionResult Index(RenderModel model) 15 | { 16 | return base.Index(model); 17 | } 18 | 19 | public ActionResult Index(ArticleSearchParameters parameters) 20 | { 21 | var response = UmbracoSearchFactory.Client.Query(new ArticleSearchQuery(parameters)); 22 | var model = new SearchResultModel(CurrentPage); 23 | model.SetSearchResult(response); 24 | return CurrentTemplate(model); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/Models/SearchResultModel.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using Nest.Searchify.Abstractions; 3 | using Umbraco.Core.Models; 4 | using Umbraco.Web.Models; 5 | 6 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search.Models 7 | { 8 | public class SearchResultModel : RenderModel where TSearchResult : ISearchResult 9 | where TParameters : class, IPagingParameters, ISortingParameters, new() where TDocument : class 10 | { 11 | public SearchResultModel(IPublishedContent content, CultureInfo culture) : base(content, culture) 12 | { 13 | } 14 | 15 | public SearchResultModel(IPublishedContent content) : base(content) 16 | { 17 | } 18 | 19 | public void SetSearchResult(TSearchResult result) 20 | { 21 | Results = result; 22 | } 23 | 24 | public TSearchResult Results { get; private set; } 25 | } 26 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/Queries/Article/ArticleDocument.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search.Queries.Article 4 | { 5 | [ElasticType(Name = "dtArticle", IdProperty = "Id")] 6 | public class ArticleDocument : UmbracoDocument 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/Queries/Article/ArticleSearchParameters.cs: -------------------------------------------------------------------------------- 1 | using Nest.Searchify.Queries; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search.Queries.Article 4 | { 5 | public class ArticleSearchParameters : SearchParameters 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/Queries/Article/ArticleSearchQuery.cs: -------------------------------------------------------------------------------- 1 | using Nest.Searchify.Queries; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search.Queries.Article 4 | { 5 | public class ArticleSearchQuery : SearchParametersFilteredQuery 6 | { 7 | public ArticleSearchQuery(ArticleSearchParameters parameters) : base(parameters) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/Queries/Article/ArticleSearchResult.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Nest.Searchify.SearchResults; 3 | 4 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search.Queries.Article 5 | { 6 | public class ArticleSearchResult : SearchResult 7 | { 8 | public ArticleSearchResult(ArticleSearchParameters parameters, ISearchResponse response) : base(parameters, response) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/Queries/Image/ImageDocument.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search.Queries.Image 4 | { 5 | [ElasticType(Name = "image", IdProperty = "Id")] 6 | public class ImageDocument : UmbracoDocument 7 | { 8 | public string Extension { get; set; } 9 | public long Size { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/Queries/UmbracoDocument.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Umbraco.Elasticsearch.Core; 3 | 4 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search.Queries 5 | { 6 | public class UmbracoDocument : IUmbracoDocument 7 | { 8 | [ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] 9 | public string Id { get; set; } 10 | 11 | [ElasticProperty(Analyzer = "indexify_english")] 12 | public string Title { get; set; } 13 | 14 | [ElasticProperty(Analyzer = "indexify_english")] 15 | public string Summary { get; set; } 16 | 17 | [ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] 18 | public string Url { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/Services/Article/ArticleContentIndexService.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Umbraco.Core.Models; 3 | using Umbraco.Elasticsearch.Core.Content.Impl; 4 | using Umbraco.Elasticsearch.Samplev73.Features.Search.Queries.Article; 5 | using Umbraco.Web; 6 | 7 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search.Services.Article 8 | { 9 | public class ArticleContentIndexService : ContentIndexService 10 | { 11 | protected override void Create(ArticleDocument doc, IContent content) 12 | { 13 | doc.Title = content.Name; 14 | doc.Summary = content.GetValue("summary"); 15 | } 16 | 17 | public ArticleContentIndexService(IElasticClient client, UmbracoContext umbracoContext) : base(client, umbracoContext) 18 | { 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/Services/Image/ImageMediaIndexService.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Umbraco.Core; 3 | using Umbraco.Core.Models; 4 | using Umbraco.Elasticsearch.Core.Media.Impl; 5 | using Umbraco.Elasticsearch.Samplev73.Features.Search.Queries.Image; 6 | using Umbraco.Web; 7 | 8 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search.Services.Image 9 | { 10 | public class ImageMediaIndexService : MediaIndexService 11 | { 12 | protected override void Create(ImageDocument doc, IMedia entity) 13 | { 14 | doc.Extension = entity.GetValue("umbracoExtension"); 15 | var bytesAttempt = entity.GetValue("umbracoBytes").TryConvertTo(); 16 | if (bytesAttempt.Success) 17 | { 18 | doc.Size = bytesAttempt.Result; 19 | } 20 | } 21 | 22 | public ImageMediaIndexService(IElasticClient client, UmbracoContext umbracoContext) : base(client, umbracoContext) 23 | { 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Features/Search/UmbracoElasticsearchStartup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Web; 4 | using Nest; 5 | using Umbraco.Elasticsearch.Core; 6 | using Umbraco.Elasticsearch.Core.Config; 7 | using Umbraco.Elasticsearch.Core.Content; 8 | using Umbraco.Elasticsearch.Core.EventHandlers; 9 | using Umbraco.Elasticsearch.Core.Impl; 10 | using Umbraco.Elasticsearch.Core.Media; 11 | using Umbraco.Elasticsearch.Samplev73.Features.Search.Services.Article; 12 | using Umbraco.Elasticsearch.Samplev73.Features.Search.Services.Image; 13 | using Umbraco.Web; 14 | 15 | namespace Umbraco.Elasticsearch.Samplev73.Features.Search 16 | { 17 | public class UmbracoElasticsearchStartup : SearchApplicationEventHandler 18 | { 19 | public UmbracoElasticsearchStartup() 20 | { 21 | SearchifyMvcConfig.Configure(HttpContext.Current.ApplicationInstance); 22 | } 23 | 24 | // Override to customise client setup 25 | protected override IElasticClient ConfigureElasticClient(FromConfigSearchSettings searchSettings, string indexName) 26 | { 27 | var connection = new ConnectionSettings(new Uri(searchSettings.Host), indexName); 28 | connection.EnableTrace(); 29 | connection.ExposeRawResponse(); 30 | connection.PrettyJson(); 31 | return new ElasticClient(connection); 32 | } 33 | 34 | protected override IElasticsearchIndexCreationStrategy GetIndexCreationStrategy(IElasticClient client) 35 | { 36 | return new UmbracoElasticsearchIndexCreationStrategy(client); 37 | } 38 | 39 | protected override IEnumerable RegisterContentIndexingServices() 40 | { 41 | yield return new ArticleContentIndexService(UmbracoSearchFactory.Client, UmbracoContext.Current); 42 | } 43 | 44 | protected override IEnumerable RegisterMediaIndexingServices() 45 | { 46 | yield return new ImageMediaIndexService(UmbracoSearchFactory.Client, UmbracoContext.Current); 47 | } 48 | 49 | internal class UmbracoElasticsearchIndexCreationStrategy : ElasticsearchIndexCreationStrategy 50 | { 51 | public UmbracoElasticsearchIndexCreationStrategy(IElasticClient client) : base(client) 52 | { 53 | //AddContributor(new EnglishIndexAnalysisContributor()); 54 | //AddContributor(new IndexSettingsContributor(1, 1)); 55 | } 56 | } 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Umbraco.Elasticsearch.Samplev73")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Umbraco.Elasticsearch.Samplev73")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("01c5bfd4-238e-4bab-b2f9-674ed02c4090")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/Article.cshtml: -------------------------------------------------------------------------------- 1 | @inherits Umbraco.Web.Mvc.UmbracoTemplatePage 2 | @{ 3 | Layout = null; 4 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/Articles.cshtml: -------------------------------------------------------------------------------- 1 | @inherits UmbracoTemplatePage 2 | 3 | @functions { 4 | private void CreateContent(Attempt count) 5 | { 6 | if (count.Success && count.Result > 0) 7 | { 8 | var prefix = DateTime.UtcNow.ToString("yyyy-MM-dd:HH:mm:ss"); 9 | var total = count.Result; 10 | var svc = UmbracoContext.Application.Services; 11 | 12 | var parent = svc.ContentService.GetById(Model.Content.Id); 13 | for (var idx = 0; idx <= total; idx++) 14 | { 15 | var content = svc.ContentService.CreateContentWithIdentity(string.Format("Article {0} {1}", prefix, idx), parent, "dtArticle"); 16 | svc.ContentService.SaveAndPublishWithStatus(content, 0, false); 17 | } 18 | } 19 | } 20 | 21 | } 22 | 23 | @{ 24 | if (Request.QueryString.AllKeys.Contains("c")) 25 | { 26 | CreateContent(Request.QueryString["c"].TryConvertTo()); 27 | } 28 | var articles = Model.Content.Children(c => c.IsDocumentType("dtArticle")).ToList(); 29 | } 30 | 31 |
32 | Articles (Total: @articles.Count) 33 |
34 |
    35 | @foreach (var article in articles) 36 | { 37 |
  • @article.Name
  • 38 | } 39 |
-------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/DtSearch/DtSearch.cshtml: -------------------------------------------------------------------------------- 1 | @using Umbraco.Elasticsearch.Samplev73.Features.Search.Models 2 | @using Umbraco.Elasticsearch.Samplev73.Features.Search.Queries.Article 3 | 4 | @inherits UmbracoViewPage> 5 | 6 |
7 |

Search Results

8 |
    9 | @foreach (var item in Model.Results.Documents) 10 | { 11 |
  • 12 |

    @item.Title

    13 | @item.Summary 14 |
  • 15 | } 16 |
17 |
-------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/Home.cshtml: -------------------------------------------------------------------------------- 1 | @inherits Umbraco.Web.Mvc.UmbracoTemplatePage 2 | @{ 3 | Layout = null; 4 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/Partials/Grid/Editors/Base.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @functions { 5 | public static string EditorView(dynamic contentItem) 6 | { 7 | string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString(); 8 | view = view.ToLower().Replace(".html", ".cshtml"); 9 | 10 | if (!view.Contains("/")) { 11 | view = "grid/editors/" + view; 12 | } 13 | 14 | return view; 15 | } 16 | } 17 | @try 18 | { 19 | string editor = EditorView(Model); 20 | @Html.Partial(editor, (object)Model) 21 | } 22 | catch (Exception ex) { 23 |
@ex.ToString()
24 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/Partials/Grid/Editors/Embed.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | @Html.Raw(Model.value) 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/Partials/Grid/Editors/Macro.cshtml: -------------------------------------------------------------------------------- 1 | @inherits UmbracoViewPage 2 | @using Umbraco.Web.Templates 3 | 4 | 5 | @if (Model.value != null) 6 | { 7 | string macroAlias = Model.value.macroAlias.ToString(); 8 | ViewDataDictionary parameters = new ViewDataDictionary(); 9 | foreach (dynamic mpd in Model.value.macroParamsDictionary) 10 | { 11 | parameters.Add(mpd.Name, mpd.Value); 12 | } 13 | 14 | 15 | @Umbraco.RenderMacro(macroAlias, parameters) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/Partials/Grid/Editors/Media.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @if (Model.value != null) 5 | { 6 | var url = Model.value.image; 7 | if(Model.editor.config != null && Model.editor.config.size != null){ 8 | url += "?width=" + Model.editor.config.size.width; 9 | url += "&height=" + Model.editor.config.size.height; 10 | 11 | if(Model.value.focalPoint != null){ 12 | url += "¢er=" + Model.value.focalPoint.top +"," + Model.value.focalPoint.left; 13 | url += "&mode=crop"; 14 | } 15 | } 16 | 17 | @Model.value.altText 18 | 19 | if (Model.value.caption != null) 20 | { 21 |

@Model.value.caption

22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/Partials/Grid/Editors/Rte.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @Html.Raw(TemplateUtilities.ParseInternalLinks(Model.value.ToString())) 5 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/Partials/Grid/Editors/Textstring.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @if (Model.editor.config.markup != null) 5 | { 6 | string markup = Model.editor.config.markup.ToString(); 7 | 8 | markup = markup.Replace("#value#", Model.value.ToString()); 9 | markup = markup.Replace("#style#", Model.editor.config.style.ToString()); 10 | 11 | 12 | @Html.Raw(markup) 13 | 14 | } 15 | else 16 | { 17 | 18 |
@Model.value
19 |
20 | } 21 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Views/Shared/_SearchifyMvcParametersPartial.cshtml: -------------------------------------------------------------------------------- 1 | @model System.Collections.Specialized.NameValueCollection 2 | 3 | @foreach (var key in Model.AllKeys) 4 | { 5 | var values = Model?.GetValues(key) ?? Enumerable.Empty(); 6 | foreach (var value in values) 7 | { 8 | @Html.Hidden(key, value) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev73/default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="True" Inherits="umbraco.UmbracoDefault" trace="true" validateRequest="false" %> 2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Browsers/Form.browser: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Browsers/w3cvalidator.browser: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Data/Umbraco.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/ffd8b0e454f9fa81b9d1f0bf3016b772b9257a22/samples/Umbraco.Elasticsearch.Samplev74/App_Data/Umbraco.7z -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Data/packages/installed/installedPackages.config: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Plugins/ModelsBuilder/modelsbuilder.controller.js: -------------------------------------------------------------------------------- 1 | function modelsBuilderController($scope, umbRequestHelper, $log, $http, modelsBuilderResource) { 2 | 3 | $scope.generate = function() { 4 | $scope.generating = true; 5 | umbRequestHelper.resourcePromise( 6 | $http.post(umbRequestHelper.getApiUrl("modelsBuilderBaseUrl", "BuildModels")), 7 | 'Failed to generate.') 8 | .then(function (result) { 9 | $scope.generating = false; 10 | $scope.dashboard = result; 11 | }); 12 | }; 13 | 14 | $scope.reload = function () { 15 | $scope.ready = false; 16 | modelsBuilderResource.getDashboard().then(function (result) { 17 | $scope.dashboard = result; 18 | $scope.ready = true; 19 | }); 20 | }; 21 | 22 | function init() { 23 | modelsBuilderResource.getDashboard().then(function(result) { 24 | $scope.dashboard = result; 25 | $scope.ready = true; 26 | }); 27 | } 28 | 29 | init(); 30 | } 31 | angular.module("umbraco").controller("Umbraco.Dashboard.ModelsBuilderController", modelsBuilderController); -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Plugins/ModelsBuilder/modelsbuilder.htm: -------------------------------------------------------------------------------- 1 | 
2 | 3 |
4 | 5 |
6 | 7 |

Models Builder

8 | 9 |
10 | Loading... 11 |
12 | 13 |
14 |
15 | 16 |
17 |

Models are out-of-date. 18 |

19 |
20 | 21 |
22 |
23 |

Generating models will restart the application.

24 |
25 |
26 | 29 |
30 |
31 |
32 |
33 |
34 | 35 |
36 | Last generation failed with the following error: 37 |
{{dashboard.lastError}}
38 |
39 |
40 | 41 |
42 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Plugins/ModelsBuilder/modelsbuilder.resource.js: -------------------------------------------------------------------------------- 1 | function modelsBuilderResource($q, $http, umbRequestHelper) { 2 | 3 | return { 4 | getModelsOutOfDateStatus: function () { 5 | return umbRequestHelper.resourcePromise( 6 | $http.get(umbRequestHelper.getApiUrl("modelsBuilderBaseUrl", "GetModelsOutOfDateStatus")), 7 | "Failed to get models out-of-date status"); 8 | }, 9 | 10 | buildModels: function () { 11 | return umbRequestHelper.resourcePromise( 12 | $http.post(umbRequestHelper.getApiUrl("modelsBuilderBaseUrl", "BuildModels")), 13 | "Failed to build models"); 14 | }, 15 | 16 | getDashboard: function () { 17 | return umbRequestHelper.resourcePromise( 18 | $http.get(umbRequestHelper.getApiUrl("modelsBuilderBaseUrl", "GetDashboard")), 19 | "Failed to get dashboard"); 20 | } 21 | }; 22 | } 23 | angular.module("umbraco.resources").factory("modelsBuilderResource", modelsBuilderResource); 24 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Plugins/ModelsBuilder/package.manifest: -------------------------------------------------------------------------------- 1 | { 2 | //array of files we want to inject into the application on app_start 3 | javascript: [ 4 | '~/App_Plugins/ModelsBuilder/modelsbuilder.controller.js', 5 | '~/App_Plugins/ModelsBuilder/modelsbuilder.resource.js' 6 | ] 7 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Plugins/umbElasticsearch/assets/hourglass.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Plugins/umbElasticsearch/package.manifest: -------------------------------------------------------------------------------- 1 | { 2 | javascript: [ 3 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.resource.js", 4 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.controller.js" 5 | ], 6 | "css": [ 7 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.css" 8 | ] 9 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Plugins/umbElasticsearch/umbElasticsearch.css: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Plugins/umbElasticsearch/umbElasticsearch.resource.js: -------------------------------------------------------------------------------- 1 | /*global Umbraco */ 2 | angular.module("umbraco.resources") 3 | .factory("umbElasticsearchResource", function ($http, umbRequestHelper) { 4 | var apiUrl = function (method) { 5 | return umbRequestHelper.getApiUrl("umbElasticsearchApiUrl", method); 6 | } 7 | 8 | return { 9 | getVersionNumber: function () { 10 | return $http.get(apiUrl("SearchVersionInfo")).then(function(data) { 11 | return data.data.version; 12 | }); 13 | }, 14 | getPluginVersionInfo: function () { 15 | return $http.get(apiUrl("PluginVersionInfo")).then(function (data) { 16 | return data.data; 17 | }); 18 | }, 19 | getIndicesInfo: function () { 20 | return umbRequestHelper.resourcePromise($http.get(apiUrl("IndicesInfo"))); 21 | }, 22 | getIndexInfo: function (indexName) { 23 | return umbRequestHelper.resourcePromise($http.post(apiUrl("GetIndexInfo"), '"' + indexName + '"')); 24 | }, 25 | rebuildContentIndex: function (indexName) { 26 | return umbRequestHelper.resourcePromise($http.post(apiUrl("RebuildContentIndex"), '"' + indexName + '"')); 27 | }, 28 | rebuildMediaIndex: function (indexName) { 29 | return umbRequestHelper.resourcePromise($http.post(apiUrl("RebuildMediaIndex"), '"' + indexName + '"')); 30 | }, 31 | createIndex: function () { 32 | return umbRequestHelper.resourcePromise($http.post(apiUrl("CreateIndex"))); 33 | }, 34 | deleteIndexByName: function (indexName) { 35 | return umbRequestHelper.resourcePromise($http.post(apiUrl("DeleteIndexByName"), '"' + indexName + '"')); 36 | }, 37 | activateIndexByName: function (indexName) { 38 | return umbRequestHelper.resourcePromise($http.post(apiUrl("ActivateIndexByName"), '"' + indexName + '"')); 39 | }, 40 | getContentIndexServices: function () { 41 | return umbRequestHelper.resourcePromise($http.get(apiUrl("ContentIndexServicesList"))); 42 | }, 43 | getMediaIndexServices: function () { 44 | return umbRequestHelper.resourcePromise($http.get(apiUrl("MediaIndexServicesList"))); 45 | }, 46 | getSettings: function () { 47 | return Umbraco.Sys.ServerVariables.umbracoPlugins.umbElasticsearch; 48 | }, 49 | ping: function () { 50 | return $http.get(apiUrl("Ping")).then(function (response) { 51 | return response.data.active !== null && response.data.active === true; 52 | }); 53 | }, 54 | isBusy: function () { 55 | return umbRequestHelper.resourcePromise($http.get(apiUrl("IsBusy"))); 56 | } 57 | }; 58 | }); -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/App_Start/SearchifyMvcConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using Nest.Searchify.Mvc.Config; 3 | using Nest.Searchify.Queries; 4 | 5 | namespace Umbraco.Elasticsearch.Samplev74 6 | { 7 | public static class SearchifyMvcConfig 8 | { 9 | public static void Configure(HttpApplication application) 10 | { 11 | SearchifyMvcConfiguration.Configure(c => c 12 | .ParameterBinding(p => p 13 | .FromThisAssembly() 14 | .FromAssemblyContaining() 15 | )); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/404handlers.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/BaseRestExtensions.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 13 | 19 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/ExamineIndex.config: -------------------------------------------------------------------------------- 1 |  2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/ExamineSettings.config: -------------------------------------------------------------------------------- 1 |  2 | 9 | 10 | 11 | 12 | 16 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/FileSystemProviders.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/cs-CZ.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/da-DK.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/de-DE.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/en-GB.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/en-US.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/es-ES.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/fr-FR.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/he-IL.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/it-IT.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/ja-JP.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/ko-KR.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/nb-NO.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/nl-NL.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/pl-PL.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/pt-BR.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/ru-RU.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/sv-SE.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/Lang/zh-CN.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/UrlRewriting.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/applications.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/feedProxy.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/grid.editors.config.js: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Rich text editor", 4 | "alias": "rte", 5 | "view": "rte", 6 | "icon": "icon-article" 7 | }, 8 | { 9 | "name": "Image", 10 | "alias": "media", 11 | "view": "media", 12 | "icon": "icon-picture" 13 | }, 14 | { 15 | "name": "Macro", 16 | "alias": "macro", 17 | "view": "macro", 18 | "icon": "icon-settings-alt" 19 | }, 20 | { 21 | "name": "Embed", 22 | "alias": "embed", 23 | "view": "embed", 24 | "icon": "icon-movie-alt" 25 | }, 26 | { 27 | "name": "Headline", 28 | "alias": "headline", 29 | "view": "textstring", 30 | "icon": "icon-coin", 31 | "config": { 32 | "style": "font-size: 36px; line-height: 45px; font-weight: bold", 33 | "markup": "

#value#

" 34 | } 35 | }, 36 | { 37 | "name": "Quote", 38 | "alias": "quote", 39 | "view": "textstring", 40 | "icon": "icon-quote", 41 | "config": { 42 | "style": "border-left: 3px solid #ccc; padding: 10px; color: #ccc; font-family: serif; font-variant: italic; font-size: 18px", 43 | "markup": "
#value#
" 44 | } 45 | } 46 | ] -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/log4net.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/metablogConfig.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/scripting.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/splashes/booting.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %> 2 | 3 | <% 4 | // NH: Adds this inline check to avoid a simple codebehind file in the legacy project! 5 | if (Request["url"].ToLower().Contains("booting.aspx") || !umbraco.cms.helpers.url.ValidateProxyUrl(Request["url"], Request.Url.AbsoluteUri)) 6 | { 7 | throw new ArgumentException("Can't redirect to the requested url - it's not local or an approved proxy url", 8 | "url"); 9 | } 10 | %> 11 | 12 | 13 | 14 | The website is restarting 15 | "> 16 | 17 | 18 |

The website is restarting

19 |

Please wait for 10s while we prepare to serve the page you have requested...

20 | 21 |

22 | You can modify the design of this page by editing /config/splashes/booting.aspx 23 |

24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Config/splashes/noNodes.aspx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/ffd8b0e454f9fa81b9d1f0bf3016b772b9257a22/samples/Umbraco.Elasticsearch.Samplev74/Config/splashes/noNodes.aspx -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/Controllers/DtSearchController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using Nest.Queryify.Extensions; 3 | using Umbraco.Elasticsearch.Core; 4 | using Umbraco.Elasticsearch.Samplev74.Features.Search.Models; 5 | using Umbraco.Elasticsearch.Samplev74.Features.Search.Queries.Article; 6 | using Umbraco.Web.Models; 7 | using Umbraco.Web.Mvc; 8 | 9 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search.Controllers 10 | { 11 | public class DtSearchController : RenderMvcController 12 | { 13 | [NonAction] 14 | public override ActionResult Index(RenderModel model) 15 | { 16 | return base.Index(model); 17 | } 18 | 19 | public ActionResult Index(ArticleSearchParameters parameters) 20 | { 21 | var response = UmbracoSearchFactory.Client.Query(new ArticleSearchQuery(parameters)); 22 | var model = new SearchResultModel(CurrentPage); 23 | model.SetSearchResult(response); 24 | return CurrentTemplate(model); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/Models/SearchResultModel.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using Nest.Searchify.Abstractions; 3 | using Umbraco.Core.Models; 4 | using Umbraco.Web.Models; 5 | 6 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search.Models 7 | { 8 | public class SearchResultModel : RenderModel where TSearchResult : ISearchResult 9 | where TParameters : class, IPagingParameters, ISortingParameters, new() where TDocument : class 10 | { 11 | public SearchResultModel(IPublishedContent content, CultureInfo culture) : base(content, culture) 12 | { 13 | } 14 | 15 | public SearchResultModel(IPublishedContent content) : base(content) 16 | { 17 | } 18 | 19 | public void SetSearchResult(TSearchResult result) 20 | { 21 | Results = result; 22 | } 23 | 24 | public TSearchResult Results { get; private set; } 25 | } 26 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/Queries/Article/ArticleDocument.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search.Queries.Article 4 | { 5 | [ElasticType(Name = "dtArticle", IdProperty = "Id")] 6 | public class ArticleDocument : UmbracoDocument 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/Queries/Article/ArticleSearchParameters.cs: -------------------------------------------------------------------------------- 1 | using Nest.Searchify.Queries; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search.Queries.Article 4 | { 5 | public class ArticleSearchParameters : SearchParameters 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/Queries/Article/ArticleSearchQuery.cs: -------------------------------------------------------------------------------- 1 | using Nest.Searchify.Queries; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search.Queries.Article 4 | { 5 | public class ArticleSearchQuery : SearchParametersFilteredQuery 6 | { 7 | public ArticleSearchQuery(ArticleSearchParameters parameters) : base(parameters) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/Queries/Article/ArticleSearchResult.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Nest.Searchify.SearchResults; 3 | 4 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search.Queries.Article 5 | { 6 | public class ArticleSearchResult : SearchResult 7 | { 8 | public ArticleSearchResult(ArticleSearchParameters parameters, ISearchResponse response) : base(parameters, response) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/Queries/Image/ImageDocument.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search.Queries.Image 4 | { 5 | [ElasticType(Name = "image", IdProperty = "Id")] 6 | public class ImageDocument : UmbracoDocument 7 | { 8 | public string Extension { get; set; } 9 | public long Size { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/Queries/UmbracoDocument.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Umbraco.Elasticsearch.Core; 3 | 4 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search.Queries 5 | { 6 | public class UmbracoDocument : IUmbracoDocument 7 | { 8 | [ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] 9 | public string Id { get; set; } 10 | 11 | [ElasticProperty(Analyzer = "indexify_english")] 12 | public string Title { get; set; } 13 | 14 | [ElasticProperty(Analyzer = "indexify_english")] 15 | public string Summary { get; set; } 16 | 17 | [ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] 18 | public string Url { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/Services/Article/ArticleContentIndexService.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Umbraco.Core.Models; 3 | using Umbraco.Elasticsearch.Core.Content.Impl; 4 | using Umbraco.Elasticsearch.Samplev74.Features.Search.Queries.Article; 5 | using Umbraco.Web; 6 | 7 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search.Services.Article 8 | { 9 | public class ArticleContentIndexService : ContentIndexService 10 | { 11 | protected override void Create(ArticleDocument doc, IContent content) 12 | { 13 | doc.Title = content.Name; 14 | doc.Summary = content.GetValue("summary"); 15 | } 16 | 17 | public ArticleContentIndexService(IElasticClient client, UmbracoContext umbracoContext) : base(client, umbracoContext) 18 | { 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/Services/Image/ImageMediaIndexService.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Umbraco.Core; 3 | using Umbraco.Core.Models; 4 | using Umbraco.Elasticsearch.Core.Media.Impl; 5 | using Umbraco.Elasticsearch.Samplev74.Features.Search.Queries.Image; 6 | using Umbraco.Web; 7 | 8 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search.Services.Image 9 | { 10 | public class ImageMediaIndexService : MediaIndexService 11 | { 12 | protected override void Create(ImageDocument doc, IMedia entity) 13 | { 14 | doc.Extension = entity.GetValue("umbracoExtension"); 15 | var bytesAttempt = entity.GetValue("umbracoBytes").TryConvertTo(); 16 | if (bytesAttempt.Success) 17 | { 18 | doc.Size = bytesAttempt.Result; 19 | } 20 | } 21 | 22 | public ImageMediaIndexService(IElasticClient client, UmbracoContext umbracoContext) : base(client, umbracoContext) 23 | { 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Features/Search/UmbracoElasticsearchStartup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Web; 4 | using Nest; 5 | using Umbraco.Elasticsearch.Core; 6 | using Umbraco.Elasticsearch.Core.Content; 7 | using Umbraco.Elasticsearch.Core.EventHandlers; 8 | using Umbraco.Elasticsearch.Core.Impl; 9 | using Umbraco.Elasticsearch.Core.Media; 10 | using Umbraco.Elasticsearch.Samplev74.Features.Search.Services.Article; 11 | using Umbraco.Elasticsearch.Samplev74.Features.Search.Services.Image; 12 | using Umbraco.Web; 13 | 14 | namespace Umbraco.Elasticsearch.Samplev74.Features.Search 15 | { 16 | public class UmbracoElasticsearchStartup : SearchApplicationEventHandler 17 | { 18 | public UmbracoElasticsearchStartup() 19 | { 20 | SearchifyMvcConfig.Configure(HttpContext.Current.ApplicationInstance); 21 | } 22 | 23 | protected override IElasticsearchIndexCreationStrategy GetIndexCreationStrategy(IElasticClient client) 24 | { 25 | return new UmbracoElasticsearchIndexCreationStrategy(client); 26 | } 27 | 28 | protected override IEnumerable RegisterContentIndexingServices() 29 | { 30 | yield return new ArticleContentIndexService(UmbracoSearchFactory.Client, UmbracoContext.Current); 31 | } 32 | 33 | protected override IEnumerable RegisterMediaIndexingServices() 34 | { 35 | yield return new ImageMediaIndexService(UmbracoSearchFactory.Client, UmbracoContext.Current); 36 | } 37 | 38 | internal class UmbracoElasticsearchIndexCreationStrategy : ElasticsearchIndexCreationStrategy 39 | { 40 | public UmbracoElasticsearchIndexCreationStrategy(IElasticClient client) : base(client) 41 | { 42 | //AddContributor(new EnglishIndexAnalysisContributor()); 43 | //AddContributor(new IndexSettingsContributor(1, 1)); 44 | } 45 | } 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Umbraco.Elasticsearch.Sample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Umbraco.Elasticsearch.Sample")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1f4215b0-b63a-4955-918f-0b1bb837675e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/DtSearch/DtSearch.cshtml: -------------------------------------------------------------------------------- 1 | @inherits UmbracoViewPage> 2 | 3 |
4 |

Search Results

5 |
    6 | @foreach (var item in Model.Results.Documents) 7 | { 8 |
  • 9 |

    @item.Title

    10 | @item.Summary 11 |
  • 12 | } 13 |
14 |
-------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/Partials/Grid/Editors/Base.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @functions { 5 | public static string EditorView(dynamic contentItem) 6 | { 7 | string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString(); 8 | view = view.ToLower().Replace(".html", ".cshtml"); 9 | 10 | if (!view.Contains("/")) { 11 | view = "grid/editors/" + view; 12 | } 13 | 14 | return view; 15 | } 16 | } 17 | @try 18 | { 19 | string editor = EditorView(Model); 20 | @Html.Partial(editor, (object)Model) 21 | } 22 | catch (Exception ex) { 23 |
@ex.ToString()
24 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/Partials/Grid/Editors/Embed.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | @Html.Raw(Model.value) 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/Partials/Grid/Editors/Macro.cshtml: -------------------------------------------------------------------------------- 1 | @inherits UmbracoViewPage 2 | @using Umbraco.Web.Templates 3 | 4 | 5 | @if (Model.value != null) 6 | { 7 | string macroAlias = Model.value.macroAlias.ToString(); 8 | ViewDataDictionary parameters = new ViewDataDictionary(); 9 | foreach (dynamic mpd in Model.value.macroParamsDictionary) 10 | { 11 | parameters.Add(mpd.Name, mpd.Value); 12 | } 13 | 14 | 15 | @Umbraco.RenderMacro(macroAlias, parameters) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/Partials/Grid/Editors/Media.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @if (Model.value != null) 5 | { 6 | var url = Model.value.image; 7 | if(Model.editor.config != null && Model.editor.config.size != null){ 8 | url += "?width=" + Model.editor.config.size.width; 9 | url += "&height=" + Model.editor.config.size.height; 10 | 11 | if(Model.value.focalPoint != null){ 12 | url += "¢er=" + Model.value.focalPoint.top +"," + Model.value.focalPoint.left; 13 | url += "&mode=crop"; 14 | } 15 | } 16 | 17 | @Model.value.altText 18 | 19 | if (Model.value.caption != null) 20 | { 21 |

@Model.value.caption

22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/Partials/Grid/Editors/Rte.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @Html.Raw(TemplateUtilities.ParseInternalLinks(Model.value.ToString())) 5 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/Partials/Grid/Editors/Textstring.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @if (Model.editor.config.markup != null) 5 | { 6 | string markup = Model.editor.config.markup.ToString(); 7 | 8 | markup = markup.Replace("#value#", Model.value.ToString()); 9 | markup = markup.Replace("#style#", Model.editor.config.style.ToString()); 10 | 11 | 12 | @Html.Raw(markup) 13 | 14 | } 15 | else 16 | { 17 | 18 |
@Model.value
19 |
20 | } 21 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/Shared/_SearchifyMvcParametersPartial.cshtml: -------------------------------------------------------------------------------- 1 | @model System.Collections.Specialized.NameValueCollection 2 | 3 | @foreach (var key in Model.AllKeys) 4 | { 5 | var values = Model?.GetValues(key) ?? Enumerable.Empty(); 6 | foreach (var value in values) 7 | { 8 | @Html.Hidden(key, value) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/articles.cshtml: -------------------------------------------------------------------------------- 1 | @inherits UmbracoTemplatePage 2 | 3 | @functions { 4 | private void CreateContent(Attempt count) 5 | { 6 | if (count.Success && count.Result > 0) 7 | { 8 | var prefix = DateTime.UtcNow.ToString("yyyy-MM-dd:HH:mm:ss"); 9 | var total = count.Result; 10 | var svc = UmbracoContext.Application.Services; 11 | 12 | var parent = svc.ContentService.GetById(Model.Content.Id); 13 | for (var idx = 0; idx <= total; idx++) 14 | { 15 | var content = svc.ContentService.CreateContentWithIdentity(string.Format("Article {0} {1}", prefix, idx), parent, "dtArticle"); 16 | svc.ContentService.SaveAndPublishWithStatus(content, 0, false); 17 | } 18 | } 19 | } 20 | 21 | } 22 | 23 | @{ 24 | if (Request.QueryString.AllKeys.Contains("c")) 25 | { 26 | CreateContent(Request.QueryString["c"].TryConvertTo()); 27 | } 28 | var articles = Model.Content.Children(c => c.IsDocumentType("dtArticle")).ToList(); 29 | } 30 | 31 |
32 | Articles (Total: @articles.Count) 33 |
34 |
    35 | @foreach (var article in articles) 36 | { 37 |
  • @article.Name
  • 38 | } 39 |
-------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/dtArticle.cshtml: -------------------------------------------------------------------------------- 1 | @inherits Umbraco.Web.Mvc.UmbracoTemplatePage 2 | @{ 3 | Layout = null; 4 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Views/dtHome.cshtml: -------------------------------------------------------------------------------- 1 | @inherits Umbraco.Web.Mvc.UmbracoTemplatePage 2 | @{ 3 | Layout = null; 4 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="True" Inherits="umbraco.UmbracoDefault" trace="true" validateRequest="false" %> 2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev74/media/1001/0grkt8x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/ffd8b0e454f9fa81b9d1f0bf3016b772b9257a22/samples/Umbraco.Elasticsearch.Samplev74/media/1001/0grkt8x.png -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Browsers/Form.browser: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Browsers/w3cvalidator.browser: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Data/Models/models.hash: -------------------------------------------------------------------------------- 1 | 96f106bf91cdec3f -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Data/packages/installed/installedPackages.config: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Plugins/ModelsBuilder/modelsbuilder.controller.js: -------------------------------------------------------------------------------- 1 | function modelsBuilderController($scope, umbRequestHelper, $log, $http, modelsBuilderResource) { 2 | 3 | $scope.generate = function() { 4 | $scope.generating = true; 5 | umbRequestHelper.resourcePromise( 6 | $http.post(umbRequestHelper.getApiUrl("modelsBuilderBaseUrl", "BuildModels")), 7 | 'Failed to generate.') 8 | .then(function (result) { 9 | $scope.generating = false; 10 | $scope.dashboard = result; 11 | }); 12 | }; 13 | 14 | $scope.reload = function () { 15 | $scope.ready = false; 16 | modelsBuilderResource.getDashboard().then(function (result) { 17 | $scope.dashboard = result; 18 | $scope.ready = true; 19 | }); 20 | }; 21 | 22 | function init() { 23 | modelsBuilderResource.getDashboard().then(function(result) { 24 | $scope.dashboard = result; 25 | $scope.ready = true; 26 | }); 27 | } 28 | 29 | init(); 30 | } 31 | angular.module("umbraco").controller("Umbraco.Dashboard.ModelsBuilderController", modelsBuilderController); -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Plugins/ModelsBuilder/modelsbuilder.htm: -------------------------------------------------------------------------------- 1 | 
2 | 3 |
4 | 5 |
6 | 7 |

Models Builder

8 | 9 |
10 | Loading... 11 |
12 | 13 |
14 |
15 | 16 |
17 |

Models are out-of-date. 18 |

19 |
20 | 21 |
22 |
23 |

Generating models will restart the application.

24 |
25 |
26 | 29 |
30 |
31 |
32 |
33 |
34 | 35 |
36 | Last generation failed with the following error: 37 |
{{dashboard.lastError}}
38 |
39 |
40 | 41 |
42 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Plugins/ModelsBuilder/modelsbuilder.resource.js: -------------------------------------------------------------------------------- 1 | function modelsBuilderResource($q, $http, umbRequestHelper) { 2 | 3 | return { 4 | getModelsOutOfDateStatus: function () { 5 | return umbRequestHelper.resourcePromise( 6 | $http.get(umbRequestHelper.getApiUrl("modelsBuilderBaseUrl", "GetModelsOutOfDateStatus")), 7 | "Failed to get models out-of-date status"); 8 | }, 9 | 10 | buildModels: function () { 11 | return umbRequestHelper.resourcePromise( 12 | $http.post(umbRequestHelper.getApiUrl("modelsBuilderBaseUrl", "BuildModels")), 13 | "Failed to build models"); 14 | }, 15 | 16 | getDashboard: function () { 17 | return umbRequestHelper.resourcePromise( 18 | $http.get(umbRequestHelper.getApiUrl("modelsBuilderBaseUrl", "GetDashboard")), 19 | "Failed to get dashboard"); 20 | } 21 | }; 22 | } 23 | angular.module("umbraco.resources").factory("modelsBuilderResource", modelsBuilderResource); 24 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Plugins/ModelsBuilder/package.manifest: -------------------------------------------------------------------------------- 1 | { 2 | //array of files we want to inject into the application on app_start 3 | javascript: [ 4 | '~/App_Plugins/ModelsBuilder/modelsbuilder.controller.js', 5 | '~/App_Plugins/ModelsBuilder/modelsbuilder.resource.js' 6 | ] 7 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Plugins/umbElasticsearch/package.manifest: -------------------------------------------------------------------------------- 1 | { 2 | javascript: [ 3 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.resource.js", 4 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.controller.js" 5 | ], 6 | "css": [ 7 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.css" 8 | ] 9 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Plugins/umbElasticsearch/umbElasticsearch.css: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Plugins/umbElasticsearch/updateIndexNode.html: -------------------------------------------------------------------------------- 1 |  2 |
3 |
4 | This will re-index the current node into the active index, are you sure? 5 |
6 |
7 | 11 |
-------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/App_Start/SearchifyMvcConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using Nest.Searchify.Mvc.Config; 3 | using Nest.Searchify.Queries; 4 | 5 | namespace Umbraco.Elasticsearch.Samplev75 6 | { 7 | public static class SearchifyMvcConfig 8 | { 9 | public static void Configure(HttpApplication application) 10 | { 11 | SearchifyMvcConfiguration.Configure(c => c 12 | .ParameterBinding(p => p 13 | .FromThisAssembly() 14 | .FromAssemblyContaining() 15 | )); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/404handlers.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/BaseRestExtensions.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 13 | 19 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/ExamineIndex.config: -------------------------------------------------------------------------------- 1 |  2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/ExamineSettings.config: -------------------------------------------------------------------------------- 1 |  2 | 9 | 10 | 11 | 12 | 16 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/FileSystemProviders.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/cs-CZ.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/da-DK.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/de-DE.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/en-GB.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/en-US.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/es-ES.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/fr-FR.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/he-IL.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/it-IT.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/ja-JP.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/ko-KR.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/nb-NO.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/nl-NL.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/pl-PL.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/pt-BR.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/ru-RU.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/sv-SE.user.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/Lang/zh-CN.user.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/UrlRewriting.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/applications.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/feedProxy.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/grid.editors.config.js: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Rich text editor", 4 | "alias": "rte", 5 | "view": "rte", 6 | "icon": "icon-article" 7 | }, 8 | { 9 | "name": "Image", 10 | "alias": "media", 11 | "view": "media", 12 | "icon": "icon-picture" 13 | }, 14 | { 15 | "name": "Macro", 16 | "alias": "macro", 17 | "view": "macro", 18 | "icon": "icon-settings-alt" 19 | }, 20 | { 21 | "name": "Embed", 22 | "alias": "embed", 23 | "view": "embed", 24 | "icon": "icon-movie-alt" 25 | }, 26 | { 27 | "name": "Headline", 28 | "alias": "headline", 29 | "view": "textstring", 30 | "icon": "icon-coin", 31 | "config": { 32 | "style": "font-size: 36px; line-height: 45px; font-weight: bold", 33 | "markup": "

#value#

" 34 | } 35 | }, 36 | { 37 | "name": "Quote", 38 | "alias": "quote", 39 | "view": "textstring", 40 | "icon": "icon-quote", 41 | "config": { 42 | "style": "border-left: 3px solid #ccc; padding: 10px; color: #ccc; font-family: serif; font-variant: italic; font-size: 18px", 43 | "markup": "
#value#
" 44 | } 45 | } 46 | ] -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/log4net.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/metablogConfig.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/scripting.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/splashes/booting.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %> 2 | 3 | <% 4 | // NH: Adds this inline check to avoid a simple codebehind file in the legacy project! 5 | if (Request["url"].ToLower().Contains("booting.aspx") || !umbraco.cms.helpers.url.ValidateProxyUrl(Request["url"], Request.Url.AbsoluteUri)) 6 | { 7 | throw new ArgumentException("Can't redirect to the requested url - it's not local or an approved proxy url", 8 | "url"); 9 | } 10 | %> 11 | 12 | 13 | 14 | The website is restarting 15 | "> 16 | 17 | 18 |

The website is restarting

19 |

Please wait for 10s while we prepare to serve the page you have requested...

20 | 21 |

22 | You can modify the design of this page by editing /config/splashes/booting.aspx 23 |

24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Config/splashes/noNodes.aspx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/ffd8b0e454f9fa81b9d1f0bf3016b772b9257a22/samples/Umbraco.Elasticsearch.Samplev75/Config/splashes/noNodes.aspx -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/Controllers/DtSearchController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using Nest.Queryify.Extensions; 3 | using Umbraco.Elasticsearch.Core; 4 | using Umbraco.Elasticsearch.Samplev75.Features.Search.Models; 5 | using Umbraco.Elasticsearch.Samplev75.Features.Search.Queries.Article; 6 | using Umbraco.Web.Models; 7 | using Umbraco.Web.Mvc; 8 | 9 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search.Controllers 10 | { 11 | public class DtSearchController : RenderMvcController 12 | { 13 | [NonAction] 14 | public override ActionResult Index(RenderModel model) 15 | { 16 | return base.Index(model); 17 | } 18 | 19 | public ActionResult Index(ArticleSearchParameters parameters) 20 | { 21 | var response = UmbracoSearchFactory.Client.Query(new ArticleSearchQuery(parameters)); 22 | var model = new SearchResultModel(CurrentPage); 23 | model.SetSearchResult(response); 24 | return CurrentTemplate(model); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/Models/SearchResultModel.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using Nest.Searchify.Abstractions; 3 | using Umbraco.Core.Models; 4 | using Umbraco.Web.Models; 5 | 6 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search.Models 7 | { 8 | public class SearchResultModel : RenderModel where TSearchResult : ISearchResult 9 | where TParameters : class, IPagingParameters, ISortingParameters, new() where TDocument : class 10 | { 11 | public SearchResultModel(IPublishedContent content, CultureInfo culture) : base(content, culture) 12 | { 13 | } 14 | 15 | public SearchResultModel(IPublishedContent content) : base(content) 16 | { 17 | } 18 | 19 | public void SetSearchResult(TSearchResult result) 20 | { 21 | Results = result; 22 | } 23 | 24 | public TSearchResult Results { get; private set; } 25 | } 26 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/Queries/Article/ArticleDocument.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search.Queries.Article 4 | { 5 | [ElasticsearchType(Name = "dtArticle", IdProperty = "Id")] 6 | public class ArticleDocument : UmbracoDocument 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/Queries/Article/ArticleSearchParameters.cs: -------------------------------------------------------------------------------- 1 | using Nest.Searchify.Queries; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search.Queries.Article 4 | { 5 | public class ArticleSearchParameters : SearchParameters 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/Queries/Article/ArticleSearchQuery.cs: -------------------------------------------------------------------------------- 1 | using Nest.Searchify.Queries; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search.Queries.Article 4 | { 5 | public class ArticleSearchQuery : SearchParametersQuery 6 | { 7 | public ArticleSearchQuery(ArticleSearchParameters parameters) : base(parameters) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/Queries/Article/ArticleSearchResult.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Nest.Searchify.SearchResults; 3 | 4 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search.Queries.Article 5 | { 6 | public class ArticleSearchResult : SearchResult 7 | { 8 | public ArticleSearchResult(ArticleSearchParameters parameters, ISearchResponse response) : base(parameters, response) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/Queries/Image/ImageDocument.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | 3 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search.Queries.Image 4 | { 5 | [ElasticsearchType(Name = "image", IdProperty = "Id")] 6 | public class ImageDocument : UmbracoDocument 7 | { 8 | public string Extension { get; set; } 9 | public long Size { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/Queries/UmbracoDocument.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Umbraco.Elasticsearch.Core; 3 | 4 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search.Queries 5 | { 6 | public class UmbracoDocument : IUmbracoDocument 7 | { 8 | [Keyword] 9 | public string Id { get; set; } 10 | 11 | // [ElasticProperty(Analyzer = "indexify_english")] 12 | [Text] 13 | public string Title { get; set; } 14 | 15 | // [ElasticProperty(Analyzer = "indexify_english")] 16 | [Text] 17 | public string Summary { get; set; } 18 | 19 | [Keyword] 20 | public string Url { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/Services/Article/ArticleContentIndexService.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Umbraco.Core.Models; 3 | using Umbraco.Elasticsearch.Core.Content.Impl; 4 | using Umbraco.Elasticsearch.Samplev75.Features.Search.Queries.Article; 5 | using Umbraco.Web; 6 | 7 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search.Services.Article 8 | { 9 | public class ArticleContentIndexService : ContentIndexService 10 | { 11 | protected override void Create(ArticleDocument doc, IContent content) 12 | { 13 | doc.Title = content.Name; 14 | doc.Summary = content.GetValue("summary"); 15 | } 16 | 17 | public ArticleContentIndexService(IElasticClient client, UmbracoContext umbracoContext) : base(client, umbracoContext) 18 | { 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/Services/Image/ImageMediaIndexService.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using Umbraco.Core; 3 | using Umbraco.Core.Models; 4 | using Umbraco.Elasticsearch.Core.Media.Impl; 5 | using Umbraco.Elasticsearch.Samplev75.Features.Search.Queries.Image; 6 | using Umbraco.Web; 7 | 8 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search.Services.Image 9 | { 10 | public class ImageMediaIndexService : MediaIndexService 11 | { 12 | protected override void Create(ImageDocument doc, IMedia entity) 13 | { 14 | doc.Extension = entity.GetValue("umbracoExtension"); 15 | var bytesAttempt = entity.GetValue("umbracoBytes").TryConvertTo(); 16 | if (bytesAttempt.Success) 17 | { 18 | doc.Size = bytesAttempt.Result; 19 | } 20 | } 21 | 22 | public ImageMediaIndexService(IElasticClient client, UmbracoContext umbracoContext) : base(client, umbracoContext) 23 | { 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Features/Search/UmbracoElasticsearchStartup.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Web; 3 | using Nest; 4 | using Umbraco.Elasticsearch.Core; 5 | using Umbraco.Elasticsearch.Core.Config; 6 | using Umbraco.Elasticsearch.Core.Content; 7 | using Umbraco.Elasticsearch.Core.EventHandlers; 8 | using Umbraco.Elasticsearch.Core.Impl; 9 | using Umbraco.Elasticsearch.Core.Media; 10 | using Umbraco.Elasticsearch.Samplev75.Features.Search.Services.Article; 11 | using Umbraco.Elasticsearch.Samplev75.Features.Search.Services.Image; 12 | using Umbraco.Web; 13 | 14 | namespace Umbraco.Elasticsearch.Samplev75.Features.Search 15 | { 16 | public class UmbracoElasticsearchStartup : SearchApplicationEventHandler 17 | { 18 | public UmbracoElasticsearchStartup() 19 | { 20 | SearchifyMvcConfig.Configure(HttpContext.Current.ApplicationInstance); 21 | } 22 | 23 | protected override IElasticsearchIndexCreationStrategy GetIndexCreationStrategy(IElasticClient client, ISearchIndexNameResolver indexNameResolver) 24 | { 25 | return new UmbracoElasticsearchIndexCreationStrategy(client, indexNameResolver); 26 | } 27 | 28 | protected override IEnumerable RegisterContentIndexingServices() 29 | { 30 | yield return new ArticleContentIndexService(UmbracoSearchFactory.Client, UmbracoContext.Current); 31 | } 32 | 33 | protected override IEnumerable RegisterMediaIndexingServices() 34 | { 35 | yield return new ImageMediaIndexService(UmbracoSearchFactory.Client, UmbracoContext.Current); 36 | } 37 | 38 | internal class UmbracoElasticsearchIndexCreationStrategy : ElasticsearchIndexCreationStrategy 39 | { 40 | public UmbracoElasticsearchIndexCreationStrategy(IElasticClient client, ISearchIndexNameResolver indexNameResolver) : base(client, indexNameResolver) 41 | { 42 | } 43 | } 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Media/1001/0grkt8x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/ffd8b0e454f9fa81b9d1f0bf3016b772b9257a22/samples/Umbraco.Elasticsearch.Samplev75/Media/1001/0grkt8x.png -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Media/1002/0grkt8x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/ffd8b0e454f9fa81b9d1f0bf3016b772b9257a22/samples/Umbraco.Elasticsearch.Samplev75/Media/1002/0grkt8x.png -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Media/1003/coordinator-clipart-wedding-hearts-clip-art2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/ffd8b0e454f9fa81b9d1f0bf3016b772b9257a22/samples/Umbraco.Elasticsearch.Samplev75/Media/1003/coordinator-clipart-wedding-hearts-clip-art2.jpg -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Media/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Umbraco.Elasticsearch.Samplev75")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Umbraco.Elasticsearch.Samplev75")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("36a41d27-5851-47a3-8d51-c961bf1a1f45")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/Article.cshtml: -------------------------------------------------------------------------------- 1 | @inherits Umbraco.Web.Mvc.UmbracoTemplatePage 2 | @using ContentModels = Umbraco.Web.PublishedContentModels; 3 | @{ 4 | Layout = null; 5 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/Articles.cshtml: -------------------------------------------------------------------------------- 1 | @inherits UmbracoTemplatePage 2 | 3 | @functions { 4 | 5 | private void CreateContent(Attempt 6 | count) 7 | { 8 | if (count.Success && count.Result > 0) 9 | { 10 | var prefix = DateTime.UtcNow.ToString("yyyy-MM-dd:HH:mm:ss"); 11 | var total = count.Result; 12 | var svc = UmbracoContext.Application.Services; 13 | 14 | var parent = svc.ContentService.GetById(Model.Content.Id); 15 | for (var idx = 0; idx <= total; idx++) 16 | { 17 | var content = svc.ContentService.CreateContentWithIdentity(string.Format("Article {0} {1}", prefix, idx), parent, "dtArticle"); 18 | svc.ContentService.SaveAndPublishWithStatus(content, 0, false); 19 | } 20 | } 21 | } 22 | 23 | } 24 | 25 | @{ 26 | if (Request.QueryString.AllKeys.Contains("c")) 27 | { 28 | CreateContent(Request.QueryString["c"].TryConvertTo()); 29 | } 30 | var articles = Model.Content.Children(c => c.IsDocumentType("dtArticle")).ToList(); 31 | } 32 | 33 |
34 | Articles (Total: @articles.Count) 35 |
36 |
    37 | @foreach (var article in articles) 38 | { 39 |
  • @article.Name
  • 40 | } 41 |
42 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/DtSearch/DtSearch.cshtml: -------------------------------------------------------------------------------- 1 | @inherits UmbracoViewPage> 2 | 3 |
4 |

Search Results

5 |
    6 | @foreach (var item in Model.Results.Documents) 7 | { 8 |
  • 9 |

    @item.Title

    10 | @item.Summary 11 |
  • 12 | } 13 |
14 |
-------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/Home.cshtml: -------------------------------------------------------------------------------- 1 | @inherits UmbracoTemplatePage 2 | @using ContentModels = Umbraco.Web.PublishedContentModels; 3 | @{ 4 | Layout = null; 5 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/Partials/Grid/Editors/Base.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @functions { 5 | public static string EditorView(dynamic contentItem) 6 | { 7 | string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString(); 8 | view = view.ToLower().Replace(".html", ".cshtml"); 9 | 10 | if (!view.Contains("/")) { 11 | view = "grid/editors/" + view; 12 | } 13 | 14 | return view; 15 | } 16 | } 17 | @try 18 | { 19 | string editor = EditorView(Model); 20 | @Html.Partial(editor, (object)Model) 21 | } 22 | catch (Exception ex) { 23 |
@ex.ToString()
24 | } -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/Partials/Grid/Editors/Embed.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | @Html.Raw(Model.value) 4 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/Partials/Grid/Editors/Macro.cshtml: -------------------------------------------------------------------------------- 1 | @inherits UmbracoViewPage 2 | @using Umbraco.Web.Templates 3 | 4 | 5 | @if (Model.value != null) 6 | { 7 | string macroAlias = Model.value.macroAlias.ToString(); 8 | ViewDataDictionary parameters = new ViewDataDictionary(); 9 | foreach (dynamic mpd in Model.value.macroParamsDictionary) 10 | { 11 | parameters.Add(mpd.Name, mpd.Value); 12 | } 13 | 14 | 15 | @Umbraco.RenderMacro(macroAlias, parameters) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/Partials/Grid/Editors/Media.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @if (Model.value != null) 5 | { 6 | var url = Model.value.image; 7 | if(Model.editor.config != null && Model.editor.config.size != null){ 8 | url += "?width=" + Model.editor.config.size.width; 9 | url += "&height=" + Model.editor.config.size.height; 10 | 11 | if(Model.value.focalPoint != null){ 12 | url += "¢er=" + Model.value.focalPoint.top +"," + Model.value.focalPoint.left; 13 | url += "&mode=crop"; 14 | } 15 | } 16 | 17 | @Model.value.altText 18 | 19 | if (Model.value.caption != null) 20 | { 21 |

@Model.value.caption

22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/Partials/Grid/Editors/Rte.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @Html.Raw(TemplateUtilities.ParseInternalLinks(Model.value.ToString())) 5 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/Partials/Grid/Editors/Textstring.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Web.Templates 3 | 4 | @if (Model.editor.config.markup != null) 5 | { 6 | string markup = Model.editor.config.markup.ToString(); 7 | 8 | var UmbracoHelper = new UmbracoHelper(UmbracoContext.Current); 9 | 10 | markup = markup.Replace("#value#", UmbracoHelper.ReplaceLineBreaksForHtml(Model.value.ToString())); 11 | markup = markup.Replace("#style#", Model.editor.config.style.ToString()); 12 | 13 | 14 | @Html.Raw(markup) 15 | 16 | } 17 | else 18 | { 19 | 20 |
@Model.value
21 |
22 | } 23 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/Shared/_SearchifyMvcParametersPartial.cshtml: -------------------------------------------------------------------------------- 1 | @model System.Collections.Specialized.NameValueCollection 2 | 3 | @foreach (var key in Model.AllKeys) 4 | { 5 | var values = Model?.GetValues(key) ?? Enumerable.Empty(); 6 | foreach (var value in values) 7 | { 8 | @Html.Hidden(key, value) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Views/dtSearch.cshtml: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /samples/Umbraco.Elasticsearch.Samplev75/default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="True" Inherits="umbraco.UmbracoDefault" trace="true" validateRequest="false" %> 2 | 3 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/BusyStateManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using Umbraco.Core.Logging; 4 | 5 | namespace Umbraco.Elasticsearch.Core 6 | { 7 | public class BusyStateManager : IDisposable 8 | { 9 | public static bool IsBusy { get; private set; } 10 | 11 | public static string Message 12 | { 13 | get { return $"{_message} (Elapsed: {Elapsed.TotalSeconds:##.000} seconds)"; } 14 | private set { _message = value; } 15 | } 16 | 17 | public static string IndexName { get; private set; } 18 | 19 | private static readonly Stopwatch Stopwatch = new Stopwatch(); 20 | 21 | public static TimeSpan Elapsed => Stopwatch.Elapsed; 22 | private static readonly object Locker = new object(); 23 | private static string _message; 24 | 25 | public static IDisposable Start(string message, string indexName) 26 | { 27 | if(IsBusy) throw new InvalidOperationException("Another index operation is currently in progress, please try again later"); 28 | return new BusyStateManager(message, indexName); 29 | } 30 | 31 | private BusyStateManager(string message, string indexName) 32 | { 33 | LogHelper.Info(message); 34 | lock (Locker) 35 | { 36 | Stopwatch.Restart(); 37 | IsBusy = true; 38 | Message = message; 39 | IndexName = indexName; 40 | } 41 | } 42 | 43 | public static void UpdateMessage(string message) 44 | { 45 | LogHelper.Info(message); 46 | lock (Locker) 47 | { 48 | Message = message; 49 | } 50 | } 51 | 52 | public void End() 53 | { 54 | LogHelper.Info($"Busy state ended after {Elapsed:g}"); 55 | lock (Locker) 56 | { 57 | Stopwatch.Stop(); 58 | IsBusy = false; 59 | } 60 | } 61 | 62 | protected virtual void Dispose(bool disposing) 63 | { 64 | if (disposing) 65 | { 66 | End(); 67 | } 68 | } 69 | 70 | 71 | public void Dispose() 72 | { 73 | Dispose(true); 74 | GC.SuppressFinalize(this); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Config/DashboardHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Web.Hosting; 3 | using System.Xml.Linq; 4 | using System.Xml.XPath; 5 | 6 | namespace Umbraco.Elasticsearch.Core.Config 7 | { 8 | /// 9 | /// Class DashboardHelper. 10 | /// 11 | public static class DashboardHelper 12 | { 13 | /// 14 | /// Ensures the section. 15 | /// 16 | /// The section. 17 | /// The caption. 18 | /// The path. 19 | internal static void EnsureSection(string section, string caption, string path) 20 | { 21 | var configPath = HostingEnvironment.MapPath("~/config/dashboard.config"); 22 | if (configPath == null) 23 | return; 24 | 25 | var configXml = XDocument.Load(configPath); 26 | var dashboardXml = configXml.XPathSelectElement("//dashBoard"); 27 | if (dashboardXml != null) 28 | { 29 | var sectionXml = configXml.XPathSelectElement($"//section [@alias='{section}']"); 30 | if (sectionXml == null) 31 | { 32 | sectionXml = 33 | XElement.Parse( 34 | $"
developeradmin{path}
"); 35 | dashboardXml.Add(sectionXml); 36 | configXml.Save(configPath); 37 | } 38 | } 39 | } 40 | 41 | /// 42 | /// Removes a section. 43 | /// 44 | /// The section. 45 | /// The caption. 46 | internal static void RemoveSection(string section, string caption) 47 | { 48 | var configPath = HostingEnvironment.MapPath("~/config/dashboard.config"); 49 | if (configPath == null) 50 | return; 51 | 52 | var configXml = XDocument.Load(configPath); 53 | var sectionXml = configXml.XPathSelectElement($"//section [@alias='{section}']"); 54 | sectionXml.Remove(); 55 | configXml.Save(configPath); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Config/DefaultIndexNameResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Umbraco.Elasticsearch.Core.Config 4 | { 5 | public class DefaultIndexNameResolver : ISearchIndexNameResolver 6 | { 7 | private readonly ISearchSettings searchSettings; 8 | 9 | public DefaultIndexNameResolver(ISearchSettings searchSettings) 10 | { 11 | this.searchSettings = searchSettings; 12 | } 13 | 14 | public string ResolveUniqueIndexName(string indexName) 15 | { 16 | return $"{indexName}-{DateTimeOffset.UtcNow:yyyyMMddHHmmss}"; 17 | } 18 | 19 | public string ResolveActiveIndexName(string indexName) 20 | { 21 | var separator = string.Empty; 22 | if (!string.IsNullOrWhiteSpace(searchSettings.IndexEnvironmentPrefix)) separator = "-"; 23 | return $"{searchSettings.IndexEnvironmentPrefix}{separator}{indexName}"; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Config/FromConfigSearchSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Linq; 5 | using System.Reflection; 6 | using Umbraco.Elasticsearch.Core.Utils; 7 | 8 | namespace Umbraco.Elasticsearch.Core.Config 9 | { 10 | public class FromConfigSearchSettings : ISearchSettings 11 | { 12 | private static readonly string Prefix = $"{UmbElasticsearchConstants.Configuration.Prefix}:"; 13 | 14 | public string Host { get; } = nameof(Host).FromAppSettingsWithPrefix(Prefix, "http://localhost:9200"); 15 | 16 | public string IndexEnvironmentPrefix { get; } = GetEnvironmentPrefix(); 17 | 18 | private static string GetEnvironmentPrefix() 19 | { 20 | var value = nameof(IndexEnvironmentPrefix).FromAppSettingsWithPrefix(Prefix, "%COMPUTERNAME%"); 21 | return Environment.ExpandEnvironmentVariables(value).ToLowerInvariant(); 22 | } 23 | 24 | public string IndexName { get; } = nameof(IndexName).FromAppSettingsWithPrefix(Prefix, "umb-elasticsearch"); 25 | 26 | public IEnumerable> AdditionalData { get; } = GetAdditionalData($"{Prefix}{nameof(AdditionalData)}:"); 27 | 28 | private static IEnumerable> GetAdditionalData(string prefix) 29 | { 30 | var keys = ConfigurationManager.AppSettings.AllKeys.Where(x => x.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)).ToList(); 31 | return keys.Select(appKey => 32 | { 33 | var key = appKey.Replace(prefix, ""); 34 | return new KeyValuePair(key, ConfigurationManager.AppSettings.Get(appKey)); 35 | }); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Config/ISearchIndexNameResolver.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Elasticsearch.Core.Config 2 | { 3 | public interface ISearchIndexNameResolver 4 | { 5 | string ResolveUniqueIndexName(string indexName); 6 | string ResolveActiveIndexName(string indexName); 7 | } 8 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Config/ISearchSettings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Umbraco.Elasticsearch.Core.Config 4 | { 5 | public interface ISearchSettings 6 | { 7 | string Host { get; } 8 | string IndexEnvironmentPrefix { get; } 9 | string IndexName { get; } 10 | 11 | IEnumerable> AdditionalData { get; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Config/PluginVersionInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Elasticsearch.Core.Config 2 | { 3 | public struct PluginVersionInfo 4 | { 5 | internal PluginVersionInfo(string umbracoVersion, string pluginVersion) 6 | { 7 | UmbracoVersion = umbracoVersion; 8 | PluginVersion = pluginVersion; 9 | } 10 | 11 | public string PluginVersion { get; } 12 | public string UmbracoVersion { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Config/SearchSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Configuration; 3 | 4 | namespace Umbraco.Elasticsearch.Core.Config 5 | { 6 | public static class SearchSettings where TSearchSettings : ISearchSettings 7 | { 8 | private static TSearchSettings _current; 9 | 10 | public static TSearchSettings Current 11 | { 12 | get 13 | { 14 | if (_current == null) 15 | throw new InvalidOperationException( 16 | "please ensure Set() is called before accessing this configuration"); 17 | return _current; 18 | } 19 | } 20 | 21 | public static void Set(TSearchSettings settings) 22 | { 23 | _current = settings; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Config/SearchSettingsExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Umbraco.Core; 3 | 4 | namespace Umbraco.Elasticsearch.Core.Config 5 | { 6 | public static class SearchSettingsExtensions 7 | { 8 | public static T GetAdditionalData(this ISearchSettings settings, string key, T defaultValue = default(T)) 9 | { 10 | var keyPair = settings.AdditionalData.FirstOrDefault(x => x.Key.InvariantEquals(key)); 11 | if (!string.IsNullOrWhiteSpace(keyPair.Key)) 12 | { 13 | var attempt = keyPair.Value.TryConvertTo(); 14 | if(attempt.Success) return attempt.Result; 15 | } 16 | return defaultValue; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Config/UmbElasticsearchConstants.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Elasticsearch.Core.Config 2 | { 3 | public static class UmbElasticsearchConstants 4 | { 5 | public static class Configuration 6 | { 7 | public const string Prefix = "umbElasticsearch"; 8 | public const string IndexBatchSize = nameof(IndexBatchSize); 9 | public const string ExcludeFromIndexPropertyAlias = nameof(ExcludeFromIndexPropertyAlias); 10 | public const string DisableContentCacheUpdatedEventHook = nameof(DisableContentCacheUpdatedEventHook); 11 | public const string EnableDebugMode = nameof(EnableDebugMode); 12 | public const string EnableNodeLevelReIndex = nameof(EnableNodeLevelReIndex); 13 | } 14 | 15 | public static class Properties 16 | { 17 | public const string ExcludeFromIndexAlias = "umbElasticsearchExcludeFromIndex"; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Content/IContentIndexService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Umbraco.Core.Models; 3 | 4 | namespace Umbraco.Elasticsearch.Core.Content 5 | { 6 | public interface IContentIndexService : IContentIndexService 7 | { 8 | 9 | } 10 | 11 | public interface IContentIndexService : IIndexService where TContent : IContent 12 | { 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Content/Impl/ContentIndexService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Nest; 5 | using Umbraco.Core.Models; 6 | using Umbraco.Core.Services; 7 | using Umbraco.Elasticsearch.Core.Config; 8 | using Umbraco.Elasticsearch.Core.Impl; 9 | using Umbraco.Web; 10 | 11 | namespace Umbraco.Elasticsearch.Core.Content.Impl 12 | { 13 | public abstract class ContentIndexService : 14 | ContentIndexService 15 | where TUmbracoDocument : class, IUmbracoDocument, new() 16 | 17 | { 18 | protected ContentIndexService(IElasticClient client, UmbracoContext umbracoContext, FromConfigSearchSettings searchSettings) : base(client, umbracoContext, searchSettings) 19 | { 20 | } 21 | 22 | protected ContentIndexService(IElasticClient client, UmbracoContext umbracoContext) : this(client, umbracoContext, SearchSettings.Current) 23 | { 24 | } 25 | } 26 | 27 | 28 | public abstract class ContentIndexService : IndexService, IContentIndexService 29 | where TUmbracoDocument : class, IUmbracoDocument, new() 30 | where TSearchSettings : ISearchSettings 31 | { 32 | protected ContentIndexService(IElasticClient client, UmbracoContext umbracoContext, TSearchSettings searchSettings) : base(client, umbracoContext, searchSettings) { } 33 | 34 | protected sealed override IEnumerable RetrieveIndexItems(ServiceContext serviceContext) 35 | { 36 | var contentType = serviceContext.ContentTypeService.GetContentType(DocumentTypeName); 37 | return serviceContext.ContentService.GetContentOfContentType(contentType.Id).Where(x => x.Published); 38 | } 39 | 40 | public sealed override bool ShouldIndex(IContent entity) 41 | { 42 | return entity.ContentType.Alias.Equals(IndexTypeName, StringComparison.CurrentCultureIgnoreCase); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Content/Impl/ContentIndexer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Umbraco.Core.Logging; 7 | 8 | namespace Umbraco.Elasticsearch.Core.Content.Impl 9 | { 10 | public class ContentIndexer : IEntityIndexer 11 | { 12 | public void Build(string indexName) 13 | { 14 | var indexExists = UmbracoSearchFactory.Client.IndexExists(indexName)?.Exists ?? false; 15 | if (!indexExists) throw new InvalidOperationException($"'{indexName}' not available, please ensure you have created an index with this name"); 16 | using (BusyStateManager.Start($"Building content for {indexName}", indexName)) 17 | { 18 | LogHelper.Info($"Started building index [{indexName}]"); 19 | 20 | foreach (var indexService in UmbracoSearchFactory.GetContentIndexServices()) 21 | { 22 | try 23 | { 24 | LogHelper.Info($"Started to index content for {indexService.DocumentTypeName}"); 25 | BusyStateManager.UpdateMessage($"Indexing {indexService.DocumentTypeName}"); 26 | indexService.Build(indexName); 27 | } 28 | catch (Exception ex) 29 | { 30 | LogHelper.Error($"Failed to index content for {indexService.DocumentTypeName}", 31 | ex); 32 | } 33 | } 34 | LogHelper.Info( 35 | $"Finished building index [{indexName}] : elapsed {BusyStateManager.Elapsed:g}"); 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/IElasticsearchIndexCreationStrategy.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Umbraco.Elasticsearch.Core 4 | { 5 | public interface IElasticsearchIndexCreationStrategy 6 | { 7 | void Create(); 8 | Task CreateAsync(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/IEntityIndexer.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Elasticsearch.Core 2 | { 3 | public interface IEntityIndexer 4 | { 5 | void Build(string indexName); 6 | } 7 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/IIndexManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using Nest; 5 | using Newtonsoft.Json.Linq; 6 | using Umbraco.Elasticsearch.Core.Impl; 7 | 8 | namespace Umbraco.Elasticsearch.Core 9 | { 10 | public interface IIndexManager 11 | { 12 | Task CreateAsync(bool activate = false); 13 | Task ActivateIndexAsync(string indexName); 14 | Task DeleteIndexAsync(string indexName); 15 | 16 | Task> IndicesInfo(); 17 | 18 | Task GetElasticsearchVersion(); 19 | 20 | Task GetIndexMappingInfo(string indexName); 21 | } 22 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/IIndexService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Umbraco.Core.Models; 4 | using Umbraco.Core.Services; 5 | 6 | namespace Umbraco.Elasticsearch.Core 7 | { 8 | /// 9 | /// An index service is responsible for the creation and indexing of a node derived from 10 | /// 11 | /// 12 | public interface IIndexService where TEntity : IContentBase 13 | { 14 | void Build(string indexName, Func> customRetrieveFunc = null); 15 | 16 | void Index(TEntity entity, string indexName); 17 | void Remove(TEntity entity, string indexName); 18 | 19 | bool IsExcludedFromIndex(TEntity entity); 20 | 21 | bool ShouldIndex(TEntity entity); 22 | 23 | void UpdateIndexTypeMapping(string indexName); 24 | 25 | string EntityTypeName { get; } 26 | 27 | string DocumentTypeName { get; } 28 | 29 | long CountOfDocumentsForIndex(string indexName); 30 | } 31 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/IUmbracoDocument.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Elasticsearch.Core 2 | { 3 | /// 4 | /// Represents the minimal requirements of the document to be indexed 5 | /// 6 | public interface IUmbracoDocument 7 | { 8 | /// 9 | /// Gets or sets the Id field for the document, this is typically the id of the umbraco node 10 | /// 11 | string Id { get; set; } 12 | /// 13 | /// Gets or sets the Url to the node represented by this document 14 | /// 15 | /// Recommendation: make this a relative url 16 | string Url { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Impl/ElasticsearchIndexCreationStrategy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Nest; 4 | using Umbraco.Elasticsearch.Core.Config; 5 | 6 | namespace Umbraco.Elasticsearch.Core.Impl 7 | { 8 | public abstract class ElasticsearchIndexCreationStrategy : IElasticsearchIndexCreationStrategy 9 | { 10 | private readonly IElasticClient client; 11 | private readonly ISearchIndexNameResolver indexNameResolver; 12 | 13 | protected ElasticsearchIndexCreationStrategy(IElasticClient client, ISearchIndexNameResolver indexNameResolver) 14 | { 15 | this.client = client; 16 | this.indexNameResolver = indexNameResolver; 17 | } 18 | 19 | protected virtual CreateIndexDescriptor WithCreateIndexDescriptor(CreateIndexDescriptor descriptor) 20 | { 21 | return descriptor; 22 | } 23 | 24 | protected CreateIndexDescriptor WithCreateIndexDescriptorCore(CreateIndexDescriptor descriptor) 25 | { 26 | return WithCreateIndexDescriptor(descriptor); 27 | } 28 | 29 | public void Create() 30 | { 31 | var newindexName = indexNameResolver.ResolveUniqueIndexName(UmbracoSearchFactory.ActiveIndexName); 32 | 33 | var result = client.CreateIndex(newindexName, WithCreateIndexDescriptorCore); 34 | 35 | if (result.IsValid) 36 | { 37 | Parallel.ForEach(UmbracoSearchFactory.GetContentIndexServices(), c => c.UpdateIndexTypeMapping(newindexName)); 38 | Parallel.ForEach(UmbracoSearchFactory.GetMediaIndexServices(), c => c.UpdateIndexTypeMapping(newindexName)); 39 | } 40 | } 41 | 42 | public async Task CreateAsync() 43 | { 44 | var newindexName = indexNameResolver.ResolveUniqueIndexName(UmbracoSearchFactory.ActiveIndexName); 45 | 46 | var result = await client.CreateIndexAsync(newindexName, WithCreateIndexDescriptorCore).ConfigureAwait(false); 47 | 48 | if (result.IsValid) 49 | { 50 | Parallel.ForEach(UmbracoSearchFactory.GetContentIndexServices(), c => c.UpdateIndexTypeMapping(newindexName)); 51 | Parallel.ForEach(UmbracoSearchFactory.GetMediaIndexServices(), c => c.UpdateIndexTypeMapping(newindexName)); 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Media/IMediaIndexService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Umbraco.Core.Models; 3 | 4 | namespace Umbraco.Elasticsearch.Core.Media 5 | { 6 | public interface IMediaIndexService : IIndexService where TMedia : IMedia 7 | { 8 | } 9 | 10 | public interface IMediaIndexService : IMediaIndexService { } 11 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Media/Impl/MediaIndexService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Nest; 5 | using Umbraco.Core.Models; 6 | using Umbraco.Core.Services; 7 | using Umbraco.Elasticsearch.Core.Config; 8 | using Umbraco.Elasticsearch.Core.Impl; 9 | using Umbraco.Web; 10 | 11 | namespace Umbraco.Elasticsearch.Core.Media.Impl 12 | { 13 | public abstract class MediaIndexService : MediaIndexService 14 | where TMediaDocument : class, IUmbracoDocument, new() 15 | { 16 | protected MediaIndexService(IElasticClient client, UmbracoContext umbracoContext, FromConfigSearchSettings searchSettings) : base(client, umbracoContext, searchSettings) 17 | { 18 | } 19 | 20 | protected MediaIndexService(IElasticClient client, UmbracoContext umbracoContext) : this(client, umbracoContext, SearchSettings.Current) 21 | { 22 | } 23 | } 24 | 25 | public abstract class MediaIndexService : IndexService, IMediaIndexService 26 | where TMediaDocument : class, IUmbracoDocument, new() 27 | where TSearchSettings : ISearchSettings 28 | { 29 | protected MediaIndexService(IElasticClient client, UmbracoContext umbracoContext, TSearchSettings searchSettings) : base(client, umbracoContext, searchSettings) { } 30 | 31 | protected sealed override IEnumerable RetrieveIndexItems(ServiceContext serviceContext) 32 | { 33 | var mediaType = serviceContext.ContentTypeService.GetMediaType(DocumentTypeName); 34 | return serviceContext.MediaService.GetMediaOfMediaType(mediaType.Id).Where(x => !x.Trashed); 35 | } 36 | 37 | public sealed override bool ShouldIndex(IMedia entity) 38 | { 39 | return entity.ContentType.Alias.Equals(IndexTypeName, StringComparison.CurrentCultureIgnoreCase); 40 | } 41 | 42 | protected override string UrlFor(IMedia contentInstance) 43 | { 44 | var helper = new UmbracoHelper(UmbracoContext.Current); 45 | var media = helper.TypedMedia(contentInstance.Id); 46 | return media.Url(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Media/Impl/MediaIndexer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Umbraco.Core.Logging; 3 | 4 | namespace Umbraco.Elasticsearch.Core.Media.Impl 5 | { 6 | public class MediaIndexer : IEntityIndexer 7 | { 8 | public void Build(string indexName) 9 | { 10 | var indexExists = UmbracoSearchFactory.Client.IndexExists(indexName)?.Exists ?? false; 11 | if (!indexExists) throw new InvalidOperationException($"'{indexName}' not available, please ensure you have created an index with this name"); 12 | using (BusyStateManager.Start($"Building media for {indexName}", indexName)) 13 | { 14 | LogHelper.Info($"Started building index [{indexName}]"); 15 | foreach (var indexService in UmbracoSearchFactory.GetMediaIndexServices()) 16 | { 17 | try 18 | { 19 | LogHelper.Info($"Started to index media for {indexService.DocumentTypeName}"); 20 | BusyStateManager.UpdateMessage($"Indexing {indexService.DocumentTypeName}"); 21 | indexService.Build(indexName); 22 | } 23 | catch (Exception ex) 24 | { 25 | LogHelper.Error($"Failed to index media for {indexService.DocumentTypeName}", ex); 26 | } 27 | } 28 | LogHelper.Info( 29 | $"Finished building index [{indexName}] : elapsed {BusyStateManager.Elapsed:g}"); 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("Umbraco.Elasticsearch.Core")] 4 | [assembly: AssemblyDescription("Provides integration between Umbraco content and media, and Elasticsearch as a search platform")] 5 | 6 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Umbraco.Elasticsearch.Core.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | Phil Oyston 7 | Phil Oyston, Storm ID 8 | https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/master/LICENSE 9 | https://github.com/Philo/Umbraco.Elasticsearch 10 | https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/master/lib/icons/umbraco-es.png 11 | false 12 | $description$ 13 | Umbraco Elasticsearch search 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Utils/ConfigurationManagerUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace Umbraco.Elasticsearch.Core.Utils 4 | { 5 | public static class ConfigurationManagerUtils 6 | { 7 | public static string FromAppSettings(this string key) 8 | { 9 | return GetAppSetting(key, null, null); 10 | } 11 | 12 | public static string FromConnectionStrings(this string key) 13 | { 14 | return GetConnectionString(key, null, null); 15 | } 16 | 17 | public static string FromAppSettingsWithPrefix(this string key, string prefix, string @default = null) 18 | { 19 | return GetAppSetting(key, @default, prefix); 20 | } 21 | 22 | public static string FromAppSettings(this string key, string @default) 23 | { 24 | return GetAppSetting(key, @default, null); 25 | } 26 | 27 | public static string FromConnectionStrings(this string key, string @default) 28 | { 29 | return GetConnectionString(key, @default, null); 30 | } 31 | 32 | public static string FromAppSettings(this string key, string @default, string prefix) 33 | { 34 | return GetAppSetting(key, @default, prefix); 35 | } 36 | 37 | public static string FromConnectionStrings(this string key, string @default, string prefix) 38 | { 39 | return GetConnectionString(key, @default, prefix); 40 | } 41 | 42 | public static string FromConnectionStringsWithPrefix(this string key, string prefix, string @default = null) 43 | { 44 | return GetConnectionString(key, @default, prefix); 45 | } 46 | 47 | public static string GetAppSetting(string key, string @default = null, string prefix = "") 48 | { 49 | var keyToRead = string.IsNullOrWhiteSpace(prefix) ? key : $"{prefix}{key}"; 50 | var value = ConfigurationManager.AppSettings.Get(keyToRead); 51 | if (string.IsNullOrWhiteSpace(value)) 52 | { 53 | if (@default == null) throw new ConfigurationErrorsException( 54 | $"Unable to read file system configuration from app settings section [{keyToRead}]"); 55 | return @default; 56 | } 57 | return value; 58 | } 59 | 60 | public static string GetConnectionString(string key, string @default = null, string prefix = "") 61 | { 62 | var keyToRead = string.IsNullOrWhiteSpace(prefix) ? key : $"{prefix}{key}"; 63 | var connectionStringValue = ConfigurationManager.ConnectionStrings[keyToRead]; 64 | if (string.IsNullOrWhiteSpace(connectionStringValue?.ConnectionString)) 65 | { 66 | if (@default == null) throw new ConfigurationErrorsException( 67 | $"Unable to read file system configuration from connection strings section [{keyToRead}]"); 68 | return @default; 69 | } 70 | return connectionStringValue.ConnectionString; 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Utils/ContentExtensions.cs: -------------------------------------------------------------------------------- 1 | using Umbraco.Core.Models.EntityBase; 2 | 3 | namespace Umbraco.Elasticsearch.Core.Utils 4 | { 5 | public enum IndexingStatusOption 6 | { 7 | Unknown, 8 | InProgress, 9 | Success, 10 | Error 11 | } 12 | 13 | public class IndexingStatus 14 | { 15 | public IndexingStatusOption Status { get; set; } = IndexingStatusOption.Unknown; 16 | public string Message { get; set; } = ""; 17 | } 18 | 19 | public static class UmbracoEntityIndexingStateExtensions 20 | { 21 | private const string Key = "umbElasticsearchIndexingStatus"; 22 | public static void SetIndexingStatus(this IUmbracoEntity entity, IndexingStatusOption status, string message) 23 | { 24 | if (!entity.AdditionalData.ContainsKey(Key)) 25 | { 26 | entity.AdditionalData.Add(Key, new IndexingStatus() 27 | { 28 | Status = status, 29 | Message = message 30 | }); 31 | } 32 | else 33 | { 34 | var state = entity.GetIndexingStatus(); 35 | state.Status = status; 36 | state.Message = message; 37 | } 38 | } 39 | 40 | public static bool IndexSuccess(this IUmbracoEntity entity) 41 | { 42 | return entity.GetIndexingStatus().Status == IndexingStatusOption.Success; 43 | } 44 | 45 | public static bool IndexError(this IUmbracoEntity entity) 46 | { 47 | return entity.GetIndexingStatus().Status == IndexingStatusOption.Error; 48 | } 49 | 50 | public static IndexingStatus GetIndexingStatus(this IUmbracoEntity entity) 51 | { 52 | if (!entity.AdditionalData.ContainsKey(Key)) 53 | { 54 | entity.AdditionalData.Add(Key, new IndexingStatus()); 55 | } 56 | return entity.AdditionalData[Key] as IndexingStatus; 57 | } 58 | 59 | public static void ClearIndexingStatus(this IUmbracoEntity entity) 60 | { 61 | if (entity.AdditionalData.ContainsKey(Key)) 62 | { 63 | entity.AdditionalData.Remove(Key); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/Utils/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | using System.Diagnostics.Contracts; 4 | 5 | namespace Umbraco.Elasticsearch.Core.Utils 6 | { 7 | public static class EnumerableExtensions 8 | { 9 | public static IEnumerable> Page(this IEnumerable source, int pageSize) 10 | { 11 | Contract.Requires(source != null); 12 | Contract.Requires(pageSize > 0); 13 | Contract.Ensures(Contract.Result>>() != null); 14 | 15 | using (var enumerator = source.GetEnumerator()) 16 | { 17 | while (enumerator.MoveNext()) 18 | { 19 | var currentPage = new List(pageSize) 20 | { 21 | enumerator.Current 22 | }; 23 | 24 | while (currentPage.Count < pageSize && enumerator.MoveNext()) 25 | { 26 | currentPage.Add(enumerator.Current); 27 | } 28 | yield return new ReadOnlyCollection(currentPage); 29 | } 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch.Core/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/Admin/Events/SearchApplicationInstallServerVarsEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Web; 4 | using System.Web.Mvc; 5 | using System.Web.Routing; 6 | using Umbraco.Core; 7 | using Umbraco.Elasticsearch.Admin.Api; 8 | using Umbraco.Web; 9 | using Umbraco.Web.UI.JavaScript; 10 | 11 | namespace Umbraco.Elasticsearch.Admin.Events 12 | { 13 | public class SearchApplicationInstallServerVarsEventHandler : ApplicationEventHandler 14 | { 15 | protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) 16 | { 17 | InstallApiUrlServerVar(); 18 | } 19 | 20 | private void InstallApiUrlServerVar() 21 | { 22 | ServerVariablesParser.Parsing += (sender, serverVars) => 23 | { 24 | if (!serverVars.ContainsKey("umbracoUrls")) 25 | throw new Exception("Missing umbracoUrls."); 26 | var umbracoUrlsObject = serverVars["umbracoUrls"]; 27 | if (umbracoUrlsObject == null) 28 | throw new Exception("Null umbracoUrls"); 29 | var umbracoUrls = umbracoUrlsObject as Dictionary; 30 | if (umbracoUrls == null) 31 | throw new Exception("Invalid umbracoUrls"); 32 | 33 | if (HttpContext.Current == null) throw new InvalidOperationException("HttpContext is null"); 34 | var urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData())); 35 | 36 | umbracoUrls["umbElasticsearchApiUrl"] = urlHelper.GetUmbracoApiServiceBaseUrl(controller => controller.IndicesInfo()); 37 | }; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/HealthChecks/ElasticsearchHealthCheck.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using Umbraco.Elasticsearch.Core; 4 | using Umbraco.Web.HealthCheck; 5 | 6 | namespace Umbraco.Elasticsearch.HealthChecks 7 | { 8 | [HealthCheck("b6c8fe79-147b-448a-8310-d4f4796b9f9d", "Elasticsearch Health Check", Description = "Verifies the configured Elasticsearch cluster setup", Group = "Umbraco.Elasticsearch")] 9 | public class ElasticsearchHealthCheck : HealthCheck 10 | { 11 | public ElasticsearchHealthCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext) 12 | { 13 | } 14 | 15 | public override IEnumerable GetStatus() 16 | { 17 | var responding = CanCommunicateWithHost(); 18 | yield return responding; 19 | if (responding.ResultType == StatusResultType.Success) 20 | { 21 | yield return VerifyElasticsearchVersion(); 22 | } 23 | } 24 | 25 | private HealthCheckStatus VerifyElasticsearchVersion() 26 | { 27 | var versionNumber = Task.Run(UmbracoSearchFactory.GetElasticsearchVersionAsync).Result; 28 | 29 | var status = new HealthCheckStatus($"Elasticsearch version: {versionNumber}") 30 | { 31 | Description = "Elasticsearch cluster must be running at least version 5.0", 32 | ResultType = versionNumber.Major < 5 ? StatusResultType.Error : StatusResultType.Info 33 | }; 34 | return status; 35 | } 36 | 37 | public override HealthCheckStatus ExecuteAction(HealthCheckAction action) 38 | { 39 | return null; 40 | } 41 | 42 | private HealthCheckStatus CanCommunicateWithHost() 43 | { 44 | var client = UmbracoSearchFactory.Client; 45 | var result = client.Ping(p => p.Human()); 46 | 47 | return new HealthCheckStatus(result.IsValid ? "Configured host is up and responding" : result.OriginalException.Message) 48 | { 49 | ResultType = result.IsValid ? StatusResultType.Success : StatusResultType.Error 50 | }; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("Umbraco.Elasticsearch")] 4 | [assembly: AssemblyDescription("Provides integration between Umbraco content and media, and Elasticsearch as a search platform")] 5 | 6 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/Umbraco.Elasticsearch.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | Phil Oyston 7 | Phil Oyston, Storm ID 8 | https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/master/LICENSE 9 | https://github.com/Philo/Umbraco.Elasticsearch 10 | https://raw.githubusercontent.com/Philo/Umbraco.Elasticsearch/master/lib/icons/umbraco-es.png 11 | false 12 | $description$ 13 | Umbraco Elasticsearch search 14 | 15 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/content/App_Plugins/umbElasticsearch/package.manifest: -------------------------------------------------------------------------------- 1 | { 2 | javascript: [ 3 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.resource.js", 4 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.controller.js" 5 | ], 6 | "css": [ 7 | "~/App_Plugins/umbElasticsearch/umbElasticsearch.css" 8 | ] 9 | } -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/content/App_Plugins/umbElasticsearch/umbElasticsearch.css: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/content/App_Plugins/umbElasticsearch/updateIndexNode.html: -------------------------------------------------------------------------------- 1 |  2 |
3 |
4 | This will re-index the current node into the active index, are you sure? 5 |
6 |
7 | 11 |
-------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/content/dashboard.config.install.xdt: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | developer 17 | 18 | 19 | 20 | admin 21 | 22 | 23 | /App_Plugins/umbElasticsearch/umbElasticsearch.html 24 | 25 | 26 |
27 |
-------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/content/dashboard.config.uninstall.xdt: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/content/web.config.install.xdt: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/content/web.config.uninstall.xdt: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Umbraco.Elasticsearch/readme.txt: -------------------------------------------------------------------------------- 1 | Umbraco.Elasticsearch 2 | --------------------- 3 | 4 | Visit http://github.com/philo/umbraco.elasticsearch 5 | 6 | Post-installation steps 7 | ----------------------- 8 | 9 | You will need to configure the location of your Elasticsearch cluster as well as any other search settings, these are configured via the section if you are using the default search settings implementation: 10 | 11 | 12 | 13 | 14 | 15 | These are the default values used if the keys above are not specified, you should alter the IndexName and if required the host, but I would recommend leaving the IndexEnvironmentPrefix as is for local development if you are using a shared cluster. For other deployments I recommend settings a fixed prefix for this such as "production", "live", "test" etc. 16 | 17 | --- 18 | 19 | If you dont already have one, you will need to setup a SearchApplicationEventHandler like the one below: 20 | 21 | public class UmbracoElasticsearchStartup : SearchApplicationEventHandler 22 | { 23 | protected override IElasticsearchIndexCreationStrategy GetIndexCreationStrategy(IElasticClient client) 24 | { 25 | return new UmbracoElasticsearchIndexCreationStrategy(client); 26 | } 27 | 28 | protected override IEnumerable RegisterContentIndexingServices() 29 | { 30 | return Enumerable.Empty(); 31 | } 32 | 33 | protected override IEnumerable RegisterMediaIndexingServices() 34 | { 35 | return Enumerable.Empty(); 36 | } 37 | 38 | internal class UmbracoElasticsearchIndexCreationStrategy : ElasticsearchIndexCreationStrategy 39 | { 40 | public UmbracoElasticsearchIndexCreationStrategy(IElasticClient client) : base(client) 41 | { 42 | AddContributor(new EnglishIndexAnalysisContributor()); 43 | AddContributor(new IndexSettingsContributor(1, 1)); 44 | } 45 | } 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /tools/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | --------------------------------------------------------------------------------