Skip to content

Touch up of IElasticClient XMLDoc #598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions new_docs/contents/nest/search/suggest.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
template: layout.jade
title: Suggest
menusection: search
menuitem: suggest
---

# Suggest
The suggest feature suggests similar looking terms based on a provided text by using a suggester.

## Completion Suggester

client.Suggest<ElasticSearchProject>(s => s
.Completion("my-suggestion", c => c
.Text("test")));

You can also use fuzzy parameters, either by specifying edit distance and such:

client.Suggest<ElasticSearchProject>(s => s
.Completion("my-suggestion", c => c
.Text("test")
.Fuzzy(f => f
.EditDistance(2)
.Transpositions(false)
.MinLength(5)
.PrefixLength(4))));

Or by using the Fuzziness variant:

client.Suggest<ElasticSearchProject>(s => s
.Completion("my-suggestion", c => c
.Text("test")
.Fuzziness();
19 changes: 16 additions & 3 deletions src/Nest/DSL/Suggest/CompletionSuggestDescriptor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nest.Resolvers;
using Nest.DSL.Suggest;
using Nest.Resolvers;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
Expand All @@ -12,13 +13,13 @@ namespace Nest
public class CompletionSuggestDescriptor<T> : BaseSuggestDescriptor<T> where T : class
{
[JsonProperty(PropertyName = "fuzzy")]
internal FuzzySuggestDescriptor<T> _Fuzzy { get; set; }
internal IFuzzySuggestDescriptor<T> _Fuzzy { get; set; }

public CompletionSuggestDescriptor<T> Size(int size)
{
this._Size = size;
return this;
}
}

public CompletionSuggestDescriptor<T> Text(string text)
{
Expand Down Expand Up @@ -49,5 +50,17 @@ public CompletionSuggestDescriptor<T> Fuzzy()
this._Fuzzy = new FuzzySuggestDescriptor<T>();
return this;
}

public CompletionSuggestDescriptor<T> Fuzziness(Func<FuzzinessSuggestDescriptor<T>, FuzzinessSuggestDescriptor<T>> fuzzinessDescriptor)
{
this._Fuzzy = fuzzinessDescriptor(new FuzzinessSuggestDescriptor<T>());
return this;
}

public CompletionSuggestDescriptor<T> Fuzziness()
{
this._Fuzzy = new FuzzinessSuggestDescriptor<T>();
return this;
}
}
}
34 changes: 34 additions & 0 deletions src/Nest/DSL/Suggest/FuzzinessSuggestDescriptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Newtonsoft.Json;

namespace Nest.DSL.Suggest
{
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class FuzzinessSuggestDescriptor<T> : IFuzzySuggestDescriptor<T> where T : class
{
[JsonProperty(PropertyName = "fuzziness")]
internal object _Fuzziness { get; private set; }

public FuzzinessSuggestDescriptor()
{
this._Fuzziness = new object();
}

public FuzzinessSuggestDescriptor<T> Fuzziness(string fuzziness)
{
this._Fuzziness = fuzziness;
return this;
}

public FuzzinessSuggestDescriptor<T> Fuzziness(int fuzziness)
{
this._Fuzziness = fuzziness;
return this;
}

public FuzzinessSuggestDescriptor<T> Fuzziness(double fuzziness)
{
this._Fuzziness = fuzziness;
return this;
}
}
}
5 changes: 3 additions & 2 deletions src/Nest/DSL/Suggest/FuzzySuggestDescriptor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Nest.DSL.Suggest;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -7,7 +8,7 @@
namespace Nest
{
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class FuzzySuggestDescriptor<T> where T : class
public class FuzzySuggestDescriptor<T> : IFuzzySuggestDescriptor<T> where T : class
{
[JsonProperty(PropertyName="edit_distance")]
internal int _EditDistance { get; set; }
Expand Down
11 changes: 11 additions & 0 deletions src/Nest/DSL/Suggest/IFuzzySuggestDescriptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nest.DSL.Suggest
{
internal interface IFuzzySuggestDescriptor<T>
{
}
}
31 changes: 17 additions & 14 deletions src/Nest/IElasticClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ISearchResponse<T> Scroll<T>(Func<ScrollDescriptor<T>, ScrollDescriptor<T>> scro
/// indicating for how long the nodes that participate in the search will maintain relevant resources in
/// order to continue and support it.</para><para>
/// This is very similar in its idea to opening a cursor against a database.</para>
/// <para> </para><para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html</para>
/// </summary>
/// <typeparam name="T">The type that represents the result hits</typeparam>
/// <param name="scrollSelector">A descriptor that describes the scroll operation</param>
Expand Down Expand Up @@ -248,7 +249,7 @@ Task<IValidateResponse> ValidateAsync<T>(Func<ValidateQueryDescriptor<T>, Valida
/// Allows to put a warmup search request on a specific index (or indices), with the body composing of a regular
/// search request. Types can be provided as part of the URI if the search request is designed to be run only
/// against the specific types.
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html#warmer-adding
/// </summary>
/// <param name="name">The name for the warmer that you want to register</param>
/// <param name="selector">A descriptor that further describes what the warmer should look like</param>
Expand All @@ -258,55 +259,55 @@ Task<IValidateResponse> ValidateAsync<T>(Func<ValidateQueryDescriptor<T>, Valida
/// Allows to put a warmup search request on a specific index (or indices), with the body composing of a regular
/// search request. Types can be provided as part of the URI if the search request is designed to be run only
/// against the specific types.
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html#warmer-adding
/// </summary>
/// <param name="name">The name for the warmer that you want to register</param>
/// <param name="selector">A descriptor that further describes what the warmer should look like</param>
Task<IIndicesOperationResponse> PutWarmerAsync(string name, Func<PutWarmerDescriptor, PutWarmerDescriptor> selector);

/// <summary>
/// Getting a warmer for specific index (or alias, or several indices) based on its name.
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html#warmer-retrieving
/// </summary>
/// <param name="name">The name of the warmer to get</param>
/// <param name="selector">An optional selector specifying additional parameters for the get warmer operation</param>
IWarmerResponse GetWarmer(string name, Func<GetWarmerDescriptor, GetWarmerDescriptor> selector = null);

/// <summary>
/// Getting a warmer for specific index (or alias, or several indices) based on its name.
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html#warmer-retrieving
/// </summary>
/// <param name="name">The name of the warmer to get</param>
/// <param name="selector">An optional selector specifying additional parameters for the get warmer operation</param>
Task<IWarmerResponse> GetWarmerAsync(string name, Func<GetWarmerDescriptor, GetWarmerDescriptor> selector = null);

/// <summary>
/// Deletes a warmer
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html#removing
/// </summary>
/// <param name="name">The name of the warmer to delete</param>
/// <param name="selector">An optional selector specifying additional parameters for the delete warmer operation</param>
IIndicesOperationResponse DeleteWarmer(string name, Func<DeleteWarmerDescriptor, DeleteWarmerDescriptor> selector = null);

/// <summary>
/// Deletes a warmer
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html#removing
/// </summary>
/// <param name="name">The name of the warmer to delete</param>
/// <param name="selector">An optional selector specifying additional parameters for the delete warmer operation</param>
Task<IIndicesOperationResponse> DeleteWarmerAsync(string name, Func<DeleteWarmerDescriptor, DeleteWarmerDescriptor> selector = null);

/// <summary>
/// Gets an index template
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html#getting
/// </summary>
/// <param name="name">The name of the template to get</param>
/// <param name="getTemplateSelector">An optional selector specifying additional parameters for the get template operation</param>
ITemplateResponse GetTemplate(string name, Func<GetTemplateDescriptor, GetTemplateDescriptor> getTemplateSelector = null);

/// <summary>
/// Gets an index template
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html#getting
/// </summary>
/// <param name="name">The name of the template to get</param>
/// <param name="getTemplateSelector">An optional selector specifying additional parameters for the get template operation</param>
Expand Down Expand Up @@ -334,15 +335,15 @@ Task<IValidateResponse> ValidateAsync<T>(Func<ValidateQueryDescriptor<T>, Valida

/// <summary>
/// Deletes an index template
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html#delete
/// </summary>
/// <param name="name">The name of the template to delete</param>
/// <param name="deleteTemplateSelector">An optional selector specifying additional parameters for the delete template operation</param>
IIndicesOperationResponse DeleteTemplate(string name, Func<DeleteTemplateDescriptor, DeleteTemplateDescriptor> deleteTemplateSelector = null);

/// <summary>
/// Deletes an index template
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html#delete
/// </summary>
/// <param name="name">The name of the template to delete</param>
/// <param name="deleteTemplateSelector">An optional selector specifying additional parameters for the delete template operation</param>
Expand Down Expand Up @@ -471,6 +472,7 @@ IPercolateCountResponse PercolateCount<T, K>(K @object, Func<PercolateCountDescr
Task<IPercolateCountResponse> PercolateCountAsync<T, K>(K @object, Func<PercolateCountDescriptor<T, K>, PercolateCountDescriptor<T, K>> percolateSelector = null)
where T : class
where K : class;

/// <summary>
/// The put mapping API allows to register specific mapping definition for a specific type.
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-put-mapping.html
Expand Down Expand Up @@ -1036,7 +1038,7 @@ Task<IBulkResponse> IndexManyAsync<T>(IEnumerable<T> objects, string index = nul

/// <summary>
/// The suggest feature suggests similar looking terms based on a provided text by using a suggester.
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-status.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters.html
/// </summary>
/// <typeparam name="T">The type used to strongly type parts of the suggest operation</typeparam>
/// <param name="selector">The suggesters to use this operation (can be multiple)</param>
Expand All @@ -1045,7 +1047,7 @@ ISuggestResponse Suggest<T>(Func<SuggestDescriptor<T>, SuggestDescriptor<T>> sel

/// <summary>
/// The suggest feature suggests similar looking terms based on a provided text by using a suggester.
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-status.html
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters.html
/// </summary>
/// <typeparam name="T">The type used to strongly type parts of the suggest operation</typeparam>
/// <param name="selector">The suggesters to use this operation (can be multiple)</param>
Expand Down Expand Up @@ -1117,15 +1119,16 @@ Task<IExistsResponse> DocumentExistsAsync<T>(Func<DocumentExistsDescriptor<T>, D
Task<IAcknowledgedResponse> DeleteRepositoryAsync(string repository, Func<DeleteRepositoryDescriptor, DeleteRepositoryDescriptor> selector = null);

/// <summary>
/// A repository can contain multiple snapshots of the same cluster. Snapshot are identified by unique names within the cluster.
/// A repository can contain multiple snapshots of the same cluster. Snapshot are identified by unique names within the cluster.
/// /// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-snapshots.html#_snapshot
/// </summary>
/// <param name="repository">The name of the repository we want to create a snapshot in</param>
/// <param name="snapshotName">The name of the snapshot</param>
/// <param name="selector">Optionally provide more details about the snapshot operation</param>
ISnapshotResponse Snapshot(string repository, string snapshotName, Func<SnapshotDescriptor, SnapshotDescriptor> selector = null);

/// <summary>
/// A repository can contain multiple snapshots of the same cluster. Snapshot are identified by unique names within the cluster.
/// A repository can contain multiple snapshots of the same cluster. Snapshot are identified by unique names within the cluster.
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-snapshots.html#_snapshot
/// </summary>
/// <param name="repository">The name of the repository we want to create a snapshot in</param>
Expand Down
2 changes: 2 additions & 0 deletions src/Nest/Nest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@
<Compile Include="DSL\Paths\IndexTypePathTypedDescriptor.cs" />
<Compile Include="DSL\SearchDescriptorBase.cs" />
<Compile Include="DSL\Search\SourceDescriptor.cs" />
<Compile Include="DSL\Suggest\FuzzinessSuggestDescriptor.cs" />
<Compile Include="DSL\Suggest\IFuzzySuggestDescriptor.cs" />
<Compile Include="DSL\UnregisterPercolatorDescriptor.cs" />
<Compile Include="DSL\DeleteTemplateDescriptor.cs" />
<Compile Include="DSL\GetTemplateDescriptor.cs" />
Expand Down
Loading