This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public SearchServiceClient GetSearchServiceClient() | |
{ | |
// El nombre del servicio es solamente la primera parte de la URL del servicio, | |
// ej.: https://miservicio.search.windows.net/ | |
string searchServiceName = "miservicio"; | |
string apiKey = "Aquí va una de las keys de administración." | |
SearchServiceClient serviceClient = new SearchServiceClient(searchServiceName, new SearchCredentials(apiKey)); | |
return serviceClient; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void CreateIndex(SearchServiceClient searchServiceClient) | |
{ | |
var index = new Index | |
{ | |
Name = "peliculas", | |
Fields = new [] | |
{ | |
new Field("peliculaId", DataType.String) { IsKey = true }, | |
new Field("titulo", DataType.String) { IsSearchable = true, IsFilterable = true }, | |
new Field("director", DataType.String) { IsSearchable = true, IsFilterable = true, IsFacetable = true }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[SerializePropertyNamesAsCamelCase] | |
public class Pelicula | |
{ | |
public string PeliculaId { get; set; } | |
public string Titulo { get; set; } | |
public string Director { get; set; } | |
public string[] Actores { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public SearchIndexClient GetIndexClientForPeliculas(SearchServiceClient serviceClient) | |
{ | |
SearchIndexClient indexClient = serviceClient.Indexes.GetClient("peliculas"); | |
return indexClient; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void UploadDocuments(SearchIndexClient indexClient) | |
{ | |
var documents = new Pelicula[] | |
{ | |
new Pelicula | |
{ | |
PeliculaId = "tt2084970", | |
Titulo = "El código enigma", | |
Director = "Morten Tyldum", | |
Actores = new [] { "Benedict Cumberbatch", "Keira Knightley", "Matthew Goode" }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<Pelicula> SearchDocuments(SearchIndexClient indexClient, string searchText, string filter = null) | |
{ | |
// Ejecutamos la búsqueda basada en un texto de búsqueda y filtros opcionales | |
var sp = new SearchParameters(); | |
if (!String.IsNullOrEmpty(filter)) | |
{ | |
sp.Filter = filter; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST https://[Nombre del servicio de Search].search.windows.net/datasources?api-version=[api-version] | |
Content-Type: application/json | |
api-key: [Key de administrador del servicio de Search] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT p.id, p.Titulo, p.Director, p.Genero, p._ts FROM Peliculas p WHERE p._ts > @HighWaterMark |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"@odata.type" : "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy", | |
"highWaterMarkColumnName" : "_ts" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"@odata.type" : "#Microsoft.Azure.Search.SoftDeleteColumnDeletionDetectionPolicy", | |
"softDeleteColumnName" : "la propiedad que especifica si un documento fue eliminado", | |
"softDeleteMarkerValue" : "el valor que identifica a un documento como borrado" | |
} |
OlderNewer