Skip to content

Instantly share code, notes, and snippets.

@yusukegoto
Created November 11, 2015 21:23
Show Gist options
  • Save yusukegoto/fe2998e9b1985759a6af to your computer and use it in GitHub Desktop.
Save yusukegoto/fe2998e9b1985759a6af to your computer and use it in GitHub Desktop.
search.cs
using Nest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace NestTester
{
/// <summary>
/// MainWindow.xaml の相互作用ロジック
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// var uri = new Uri("http://vps2.fellowrobots.com:9201/products-jp/product");
var uri = new Uri("http://vps2.fellowrobots.com:9201");
var setting = new ConnectionSettings(uri)
.SetBasicAuthentication("oshbot", "ydfn1248");
var client = new ElasticClient(setting);
var query = new SearchDescriptor<Product>()
.Index("products-jp")
.Type("product")
.Query(pp => pp.Term(ppp => ppp .Name, "sony"));
var res = client.Search<Product>(query);
comboBox.ItemsSource = res.Hits.Select(product => product.Source.Name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment