Professional Documents
Culture Documents
Terms & "test" or "‐ c.Where("tes‐ Exclusive title:‐ c.Title.Bet‐ Restriction Where var results =
Phrases hello t") or Range {Aida TO ween("Aida", Operators from d in
dolly" c.Wher‐ Carmen} "Carmen", queryable
e("hello Inclus‐ where d.Name
dolly") or ion.None) == "Sitecore"
c.Where("t‐ Boosting jakarta^4 c.Title.Equ‐ select d; or
est" || "‐ apache als("jakar‐ var results =
hello dolly") ta".Boost(4)) queryable.Wh‐
("amber") ble.Select(d
Boolean "jakarta where c.Equa‐
=> d.Name);
Prefix amber c.ContactName.S‐ And apache" ls("jakarta
amber tartsWith("am‐ AND "‐ apache") && Anonymous results =
ber") or c.Contact‐ Apache c.Equals("‐ types queryable.Se‐
Name.EndsWit‐ Lucene" Apache lect(d => new
h("amber") Lucene") { d.Name, d.Id
Fuzzy roam~ or c.ContactNa‐ Boolean "jakarta where c.Equa‐
});
roam~0.8 me.Like("r‐ Not apache" Unsupp‐ SelectMany
ls("jakarta
oam") or NOT "‐ apache") && orted
c.ContactNam‐ Apache !c.Equals‐ Partitioning Take results = querya‐
e.Like("ro‐ Lucene" ("Apache Operators ble.Take(10);
am", 0.8) Lucene") Partitioning Skip results =
Proximity "jakarta c.ContactNa‐ Grouping (jakarta where (c.Title Operators queryable.Sk‐
apache"~1 me.Like("j‐ OR ip(10);
== "jakarta"
0 akarta apache) || c.Title == Partitioning Page results =
apache", 10) AND "apache") && Operators queryable.Pa‐
Inclusive mod_da‐ c.ModifiedD‐ website (c.Title == "‐ ge(2, 100);
Range te:[20‐ ate.Betwe‐ website")
020101 en("200201‐
TO 01", "200301‐
20030101] 01", Inclus‐
ion.Both)
sitecorebasics.wordpress.com/
Sitecore Search Developers Cheat Sheet
by Kiran Patil (kpatil) via cheatography.com/20093/cs/2946/
Supported IQueryable methods (cont) Supported IQueryable methods (cont) Supported IQueryable methods (cont)
sitecorebasics.wordpress.com/
Sitecore Search Developers Cheat Sheet
by Kiran Patil (kpatil) via cheatography.com/20093/cs/2946/
== 7.Boost(2‐ d.Id.Between(1,
ontains("o")); queryable.Where(d
=> d.Id.Betw‐
een(1, 4, Inclus‐
ion.Upper)); or
results = querya‐
ble.Where(d =>
d.Id.Between(1,
4, Inclusion.No‐
ne));
sitecorebasics.wordpress.com/
Sitecore Search Developers Cheat Sheet
by Kiran Patil (kpatil) via cheatography.com/20093/cs/2946/
IQueryable Extensions (cont) IQueryable Extensions (cont) Daily Life usages (cont)
Other string.Co results = querya‐ GetResults results = querya‐ This using (var context =
ntains ble.Where(d => ble.GetResults().H‐ converts ContentSearchManag‐
!d.Template.Con‐ its.Where(i => the query er.GetIndex(item).Cre‐
tains("Hello:)); i.Document.Name.Co‐ to ateSearchContext()) {
ntains("o")).Wher‐ something IQueryable<SearchR‐
Other string.Co results = querya‐
your
mpareTo ble.Where(d => e(hit => hit.Score > esultItem> searchQuery
provider
!d.Name.Compare‐ 0.6); = context.GetQueryab‐
unders‐
To("Hello") == GetFacets results = querya‐ le<SearchResultItem>
tands. For
1); ble.Where(d => d.Id > ().Where(item =>
example,
0).FacetOn(d => item[“_name”] ==
Other Equal results = querya‐ for Lucene
d.Template, 0).Get‐ “Sitecore”) }
ble.Where(d => it is
d.Id.Equal(4)); Facets(); converted
to:
Other Matches results = querya‐
Daily Life usages _name:sit‐
ble.Where(i =>
This using (var context = ecore
i.Template.Matc‐
hes("^.*$")); returns ContentSearchManager.G‐
the etIndex(item).Create‐
Other MatchW‐ results = querya‐
results of SearchContext()) {
ildcard ble.Where(i =>
a query IQueryable<SearchResu‐
i.Template.W‐
on your ltItem> searchQuery =
here(i => i.Temp‐ search
context.GetQueryable<‐
late.MatchWildc‐ index
SearchResultItem>().W‐
ard("H?li*m"))); and
here(item => item.Name
Other Like results = querya‐ returns it
== “Sitecore”) }
ble.Where(i => as a
i.Template.Like‐ Search‐
("Citecoar")); Res‐
ultItem
Other string.St‐ results = querya‐
type.
artsWith ble.Where(d =>
!d.Name.StartsW‐
ith("Hello"));
sitecorebasics.wordpress.com/
Sitecore Search Developers Cheat Sheet
by Kiran Patil (kpatil) via cheatography.com/20093/cs/2946/
Daily Life usages (cont) Daily Life usages (cont) Daily Life usages (cont)
+ using (var context = Find all var index = ContentSe‐ find all items context.GetQueryable‐
(+_na‐ ContentSearchManager.Get‐ the items archManager.GetIndex("‐ that have <SearchResultItem>‐
me:sit‐ Index(item).CreateSearch‐ that have sitecore_master_in‐ some ().Where(resultIte‐
ecore) Context()) { IQueryabl‐ “s” in dex"); using (var content in m=>resultItem["page‐
+(titl‐ e<SearchResultItem> their context = index.Create‐ the "Page _title"]!=""
e:test searchQuery = context.G‐ names SearchContext()) { Title" field
body:‐ find all items context.GetQueryable‐
etQueryable<SearchResult‐ Console.WriteLine(
cms) that have <SearchResultItem>‐
Item>().Where(item => context.GetQueryable<‐
or (+ lorem in the
item[“_name”] == “Sitec‐ SearchResultItem>().W‐ ().Where(resultIte‐
(+_n‐ body
ore”).Where(item => here(resultItem=>resu‐ m=>resultItem["b‐
ame:si‐
item.Title == “Test || ltItem.Name.Contains("‐ ody"].Contains("lore‐
tecore)
item.Body.Contains(“C‐ s")) ); m"))
+(titl‐
e:test
MS”)) } OR using (var Finding context.GetQueryable‐ finding an context.GetQueryable‐
body:‐ context = ContentSearc‐ the first <SearchResultItem>().F‐ item where <SearchResultItem>()
cms)) hManager.GetIndex item irstOrDefault(result‐ item.Fiel‐ .Where(resultItem=‐
(item).CreateSearchConte‐ named Item=>resultItem.Name‐ ds["Tax‐ >resultItem["taxono‐
xt()) { IQueryable<Sear‐ Sitecore onomy my_items"].Contains‐
=="sitecore")
chResultItem> searchQuery Items"] // is (Sitecore.ContentS‐
Finding context.GetQueryable‐
= context.GetQueryable<‐ a multi list
the count earch.Utilities.Id‐
<SearchResultItem>().C‐
SearchResultItem> ().Whe‐ field and
of items Helper.NormalizeGuid
ount() contains "‐
re(item => item.Name == in a ("{016424DF-865C-49‐
{01642‐
“Sitecore”).Where(item => database DC-9D7A-40EB8101C7‐
4DF-865C-‐
item.Title == “Test || 17}",true)))
Finding context.GetQueryable<Search‐ 49DC-
item.Body.Contains(“CMS”)
all the ResultItem>().Where(resultI‐ 9D7A-4‐
items tem=>resultItem.Template‐ 0EB810‐
that use Name=="Sample Item") 1C717}"
a certain
template
same context.GetQueryable‐
thing as <SearchResultItem>().W‐
above here(resultItem=>res‐
but this ultItem.TemplateId==I‐
time D.Parse("{76036F5E-CBC‐
using the E-46D1 -AF0A-4143F9B55‐
template
7AA}"))
id
sitecorebasics.wordpress.com/
Sitecore Search Developers Cheat Sheet
by Kiran Patil (kpatil) via cheatography.com/20093/cs/2946/
GetLatestVersion().Versi‐ AddFieldByField‐
on.ToString()); Name">
sitecorebasics.wordpress.com/