<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ResultTableCollection arşivleri - Yunus Emre Araç</title>
	<atom:link href="https://www.yunusemrearac.com/tag/resulttablecollection/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.yunusemrearac.com/tag/resulttablecollection/</link>
	<description>SharePoint Consultant &#124; Microsoft 365 &#124; SharePoint Server &#38; Online</description>
	<lastBuildDate>Thu, 09 May 2019 08:15:50 +0000</lastBuildDate>
	<language>tr</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>

<image>
	<url>https://www.yunusemrearac.com/wp-content/uploads/2014/11/MetroUI_VisualStudio_2012-545c8860_site_icon-32x32.png</url>
	<title>ResultTableCollection arşivleri - Yunus Emre Araç</title>
	<link>https://www.yunusemrearac.com/tag/resulttablecollection/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">67294213</site>	<item>
		<title>SharePoint KeywordQuery Kullanarak Arama Sorgusu Yaparak Sonuçları Listeleme</title>
		<link>https://www.yunusemrearac.com/2019/05/08/sharepoint-keywordquery-kullanarak-arama-sorgusu-yaparak-sonuclari-listeleme/</link>
					<comments>https://www.yunusemrearac.com/2019/05/08/sharepoint-keywordquery-kullanarak-arama-sorgusu-yaparak-sonuclari-listeleme/#respond</comments>
		
		<dc:creator><![CDATA[yunusemrearac]]></dc:creator>
		<pubDate>Wed, 08 May 2019 08:08:48 +0000</pubDate>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[KeywordQuery]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Microsoft.Office.Server.Search]]></category>
		<category><![CDATA[ResultTableCollection]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[Search Service]]></category>
		<category><![CDATA[SearchExecutor]]></category>
		<category><![CDATA[SharePoint Search]]></category>
		<category><![CDATA[SPSite]]></category>
		<guid isPermaLink="false">http://yunusemrearac.com/?p=1923</guid>

					<description><![CDATA[<p>Merhaba arkadaşlar bugün sizlere SharePoint ortamında server side olarak &#8220;KeywordQuery&#8221; kullanarak nasıl sharepoint search servisini kullanarak sorgu atıp gelen sonuçları alabileceğinizden bahsedeceğim. İlk olarak oluşturduğumuz&#8230;</p>
<p>The post <a href="https://www.yunusemrearac.com/2019/05/08/sharepoint-keywordquery-kullanarak-arama-sorgusu-yaparak-sonuclari-listeleme/">SharePoint KeywordQuery Kullanarak Arama Sorgusu Yaparak Sonuçları Listeleme</a> appeared first on <a href="https://www.yunusemrearac.com">Yunus Emre Araç</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Merhaba arkadaşlar bugün sizlere SharePoint ortamında server side olarak <strong>&#8220;KeywordQuery&#8221;</strong> kullanarak nasıl sharepoint search servisini kullanarak sorgu atıp gelen sonuçları alabileceğinizden bahsedeceğim.</p>
<p>İlk olarak oluşturduğumuz projeye <strong>&#8220;Microsoft.Office.Server.Search&#8221;</strong> referansını ekliyoruz.</p>
<p>Oluşturduğumuz webpartımızın ascx tarafında arama textbox ımızı, butonumuzu ve sonuçların listeleneceği repeater kontrollerimizi ekliyoruz.</p><pre class="urvanov-syntax-highlighter-plain-tag">&lt;asp:TextBox ID="searchText" runat="server"&gt;&lt;/asp:TextBox&gt;
&lt;asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Search" /&gt;

&lt;asp:Repeater ID="rptSearch" runat="server"&gt;
    &lt;ItemTemplate&gt;
        &lt;p&gt;&lt;a href="&lt;%# Eval("Url") %&gt;"&gt;&lt;%# Eval("Title") %&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/ItemTemplate&gt;
&lt;/asp:Repeater&gt;</pre><p>Daha sonra code behind tarafına geçerek burada sonuçlarımıza uygun bir sınıf oluşturuyoruz.</p><pre class="urvanov-syntax-highlighter-plain-tag">public class SearchResult
{
    public string Title { set; get; }
    public string Url { set; get; }
}</pre><p>Sonrasında ascx tarafında otamatik oluşturmuş olduğumuz <strong>&#8220;btnSearch_Click&#8221;</strong> eventımızın içine giderek kodumuzu yazmaya devam ediyoruz.</p>
<p>İlk olarak sitemizde arama yaptıracağımız için <strong>SPSite</strong> ile site bağlantımızı yapmamız gerekmektedir.</p><pre class="urvanov-syntax-highlighter-plain-tag">SPSite site = SPContext.Current.Site;</pre><p>Bu tanımlamadan sonra ilk olarak sorgu parametrelerini tanımlamak için <strong>&#8220;KeywordQuery&#8221;</strong> değişkenimizi oluşturuyoruz.</p><pre class="urvanov-syntax-highlighter-plain-tag">KeywordQuery kq = new KeywordQuery(site);</pre><p>Bu parametremiz için gerekli olan ve kullanacağımız <strong>SourceId, QueryText, SelectProperties ve RowLimit</strong> parametrelerine gerekli atamalarımızı yapıyoruz. Bu örnekte sadece bu kadar parametre kullanma ihtiyacı duydum siz bunların sayısını da arttırabilirsiniz ihtiyacınıza uygun olarak.</p><pre class="urvanov-syntax-highlighter-plain-tag">kq.SourceId = new Guid("8413cd39-2156-4e00-b54d-11efd9abdb89");
kq.QueryText = "* " + searchText.Text;
kq.SelectProperties.Add("Title");
kq.SelectProperties.Add("Path");
kq.RowLimit = 20;</pre><p>Bu kısımda:</p>
<p>SourceId kısmında verdiğimiz Guid id&#8217;si aslında daha önceki <u><a href="http://yunusemrearac.com/2019/01/07/sharepoint-pnp-js-core-search-yapisinda-arama-yapilmasini-istedigimiz-alani-ozellestirmemize-yarayan-sourceid-parametre-degerleri-ve-karsiliklari/">SharePoint PNP JS Core Search Yapısında Arama Yapılmasını İstediğimiz Alanı Özelleştirmemize Yarayan ‘SourceId’ Parametre Değerleri ve Karşılıkları</a></u> yazımda da bahsettiğim gibi genel arama kriterlerinden bahsedeceğim için bu id tanımlanmıştır.</p>
<p>QueryText parametresinde ise başta yıldız olmasının sebebi sql command&#8217;ta olduğu gibi girilen text değerinin bire bir değil içinde geçenleri de aramasını sağlamaktadır. Bu alana path vs gibi filtrelerde eklenebilmektedir. Search webpartında yer alan query kısmındaki tüm özellikleri desteklemektedir. Ekstra olarak textboxtan gelen değeri aratmak istediğim için bu alandaki text değerini de buraya ekledim.</p>
<p>SelectProperties kısmında ise gelmesini istediğimiz değerleri ekliyoruz. Burada sadece <strong>Title</strong> ve <strong>Path</strong> bilgilerinin gelmesini istediğim için bu ik değeri ekledim. İsteğe göre arttırabilirsiniz.</p>
<p>Gerekli ayarlamalarımızı yaptıktan sonra sorgumuzu atabiliriz. Aşağıdaki gibi <strong>&#8220;SearchExecutor&#8221;</strong> ile sorgumuzu atıyoruz.</p>
<p>ResultTableCollection resultTables = new SearchExecutor().ExecuteQuery(kq);</p>
<p>Sorgumuz sonucu bize <strong>&#8220;ResultTableCollection&#8221;</strong> tipinde gelecektir buradan işimize yarayacak datatable tablosunu almamız gerekmektedir.</p>
<p>DataTable resultDataTable = resultTables.FirstOrDefault().Table;</p>
<p>Buradan sonra bu tablo içerisinde gezerek kullanacağımız değerleri modellimiz formatına getirerek toplamamız gerekmektedir. Bu modelleri toplayabilmek için oluşturduğumuz model türünde liste oluşturuyoruz.</p><pre class="urvanov-syntax-highlighter-plain-tag">List&lt;SearchResult&gt; searchResultList = new List&lt;SearchResult&gt;();</pre><p>Sonuç tablomuz üzerinde gezerek modelleri oluşturup model listemize ekliyoruz.</p><pre class="urvanov-syntax-highlighter-plain-tag">foreach (DataRow row in resultDataTable.Rows)
{
    SearchResult searchResult = new SearchResult();

    searchResult.Title = row["Title"].ToString();
    searchResult.Url = row["Path"].ToString();

    searchResultList.Add(searchResult);
}</pre><p>Arama sonuçlarımızın istediğimiz modele uygun şekile getirilmiş bir halde elimiz de bir listemiz yer almaktadır. Şimdide bu listeyi ekranda görebilmek için repeater a bind ediyoruz.</p><pre class="urvanov-syntax-highlighter-plain-tag">rptSearch.DataSource = searchResultList;
rptSearch.DataBind();</pre><p>Gördüğünüz gibi bu şekilde sharepoint search alt yapısını kullanarak kendi arama uygulamamızı yazmış olduk.</p>
<p>Kodun tamamını bir verecek olursak aşağıdaki gibi bir code behind olacaktır.</p><pre class="urvanov-syntax-highlighter-plain-tag">using Microsoft.Office.Server.Search.Query;
using Microsoft.SharePoint;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web.UI;

namespace GetSharePointSearchResult.GetSharePointSearchResult
{
    public partial class GetSharePointSearchResultUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            SPSite site = SPContext.Current.Site;
            KeywordQuery kq = new KeywordQuery(site);
            kq.SourceId = new Guid("8413cd39-2156-4e00-b54d-11efd9abdb89");
            kq.QueryText = "* " + searchText.Text;
            kq.SelectProperties.Add("Title");
            kq.SelectProperties.Add("Path");
            kq.RowLimit = 20;
            ResultTableCollection resultTables = new SearchExecutor().ExecuteQuery(kq);

            DataTable resultDataTable = resultTables.FirstOrDefault().Table;

            List&lt;SearchResult&gt; searchResultList = new List&lt;SearchResult&gt;();

            foreach (DataRow row in resultDataTable.Rows)
            {
                SearchResult searchResult = new SearchResult();

                searchResult.Title = row["Title"].ToString();
                searchResult.Url = row["Path"].ToString();

                searchResultList.Add(searchResult);
            }

            rptSearch.DataSource = searchResultList;
            rptSearch.DataBind();
        }

        public class SearchResult
        {
            public string Title { set; get; }
            public string Url { set; get; }
        }
    }
}</pre><p>Sitemizde yer alan default arama ekranından arama yaptığımız da gelen sonuç ekranı aşağıdaki gibidir.</p>
<p><a href="http://yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-default-search-result.png"><img fetchpriority="high" decoding="async" class="size-full wp-image-1924 aligncenter" src="https://yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-default-search-result.png" alt="" width="1919" height="1048" srcset="https://www.yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-default-search-result.png 1919w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-default-search-result-300x164.png 300w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-default-search-result-768x419.png 768w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-default-search-result-1024x559.png 1024w" sizes="(max-width: 1919px) 100vw, 1919px" /></a></p>
<p>Birde yazdığımız arama webpartında aynı aramayı yapalım.</p>
<p><a href="http://yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-custom-search-result.png"><img decoding="async" class="size-full wp-image-1925 aligncenter" src="https://yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-custom-search-result.png" alt="" width="1919" height="1052" srcset="https://www.yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-custom-search-result.png 1919w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-custom-search-result-300x164.png 300w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-custom-search-result-768x421.png 768w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/sharepoint-site-custom-search-result-1024x561.png 1024w" sizes="(max-width: 1919px) 100vw, 1919px" /></a></p>
<p>Gördüğünüz gibi aynı sonuçları getirmektedir.</p>
<p>Projenin tamamını aşağıdaki github linkindende indirebilirsiniz.</p>
<p><a href="https://github.com/yunusemrearac/GetSharePointSearchResultWithKeywordQuery" target="_blank" rel="noopener noreferrer"><img decoding="async" class="alignnone wp-image-1789 size-medium" src="https://yunusemrearac.com/wp-content/uploads/2018/10/Github-source-code-downloa-300x120.png" alt="" width="300" height="120" srcset="https://www.yunusemrearac.com/wp-content/uploads/2018/10/Github-source-code-downloa-300x120.png 300w, https://www.yunusemrearac.com/wp-content/uploads/2018/10/Github-source-code-downloa-768x306.png 768w, https://www.yunusemrearac.com/wp-content/uploads/2018/10/Github-source-code-downloa-1024x408.png 1024w, https://www.yunusemrearac.com/wp-content/uploads/2018/10/Github-source-code-downloa.png 1254w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>The post <a href="https://www.yunusemrearac.com/2019/05/08/sharepoint-keywordquery-kullanarak-arama-sorgusu-yaparak-sonuclari-listeleme/">SharePoint KeywordQuery Kullanarak Arama Sorgusu Yaparak Sonuçları Listeleme</a> appeared first on <a href="https://www.yunusemrearac.com">Yunus Emre Araç</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yunusemrearac.com/2019/05/08/sharepoint-keywordquery-kullanarak-arama-sorgusu-yaparak-sonuclari-listeleme/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1923</post-id>	</item>
	</channel>
</rss>
