droplink and treelist values in sitecore search -



droplink and treelist values in sitecore search -

how droplink , treelist values in sitecore search . below code , config file . when searching based on droplink , treelist value not coming in search result .

var fquery = new fulltextquery(search); searchhits searchhits = sc.search(fquery, int.maxvalue); homecoming searchhits.fetchresults(0, int.maxvalue).select(r => r.getobject()).tolist();

config file entry .

i not sure if have parse them or else . looking forwards help.

you don't version of sitecore you're using, speaking works v6.6:

id-based fields, treelist store guids in sitecore database. @ index time, sitecore parses these shortid format , forces lower case. lucene index entry contains lowercase guid no curly braces or hyphens.

chances are, text-based query not going contain text match this.

i tend utilize term based booleanquery object match id-based fields. like:

booleanquery query = new booleanquery(); query.add(new termquery(new term("myfieldname", shortid.encode(myguidtomatch).tolowerinvariant())), booleanclause.occur.must);

note field name want query should in lower case, sitecore / lucene works in lower case.

you may find code , ui illustration in blog post helpful see illustration of building queries against id-based fields: http://jermdavis.wordpress.com/2014/06/09/faceted-search-in-sitecore-6-6/

if want able match values contained in these fields free text type of search box, have pre-process values these id-based fields before indexed.

sitecore , lucene allow thought of "computed fields" in index - can configure indexing process run bits of own code in order process info @ index time, , create new lucene index fields results of code.

this blog post of mine gives illustration of computed field: http://jermdavis.wordpress.com/2014/05/05/using-dms-profile-cards-as-search-metadata/ illustration not doing want - talk how might configure 1 of these custom fields.

you'd want custom field code to:

get raw value of id-based field load item id points to process item turn pattern of text want indexed return text, saved computed field in lucene

with done, should find index contain text associated id field(s). , hence should able match text-based query.

-- edited add together --

more detail on creating computed index items:

sitecore 6.6 doesn't straight back upwards computed fields in lucene indexes. them can create utilize of advanced database crawler - part of sitecore searchcontrib project available on github: https://github.com/sitecorian/sitecoresearchcontrib there assorted blog posts on getting started code.

[nb: in sitecore 7.x believe behaviour has migrated core of sitecore. think changed names of stuff. details of available via google - things upgrading sitecore 6.6 index configuration sitecore 7 (using computedfields) example]

the code dynamic field turn id-based text might like:

public class indexidfield : basedynamicfield { public override string resolvevalue(sitecore.data.items.item item) { field fld = item.fields["fieldyouareinterestedin"]; if (fld != null && !string.isnullorwhitespace(fld.value)) { string[] ids = fld.value.split('|'); stringbuilder text = new stringbuilder(); foreach (string id in ids) { item relateditem = item.database.getitem(id); if (relateditem != null) { text.append(relateditem.displayname); text.append(" "); } } homecoming text.tostring(); } homecoming null; } }

this extracting appropriate field context item that's beingness passed in. if exists , not empty, splits "|" list of ids stored in field. each 1 tries load it. note utilize of appropriate database specified input item - sitecore.context.database point core @ point, , won't find items there. finally, if valid item id, append display name our text indexed. utilize other fields display name - depending on makes sense in solution.

with code added solution need ensure it's called @ index build time. default config advanced database crawler includes config element dynamic fields. (and again, sc7.x have similar don't know names off top of head) need add together type configuration dynamic fields. snipping out extraneous bits default config:

<configuration xmlns:x="http://www.sitecore.net/xmlconfig/"> <sitecore> <!-- snip --> <search> <!-- snip --> <crawlers> <demo type="scsearchcontrib.crawler.crawlers.advanceddatabasecrawler,scsearchcontrib.crawler"> <!-- snip --> <dynamicfields hint="raw:adddynamicfields"> <!-- snip --> <dynamicfield type="yournamespace.indexidfield,yourdll" name="_myfieldname" storagetype="no" indextype="tokenized" vectortype="no" boost="1f" /> </dynamicfields> <!-- snip --> </demo> </crawlers> </search> </sitecore> </configuration>

that sets new field called "_myfieldname" sensible options indexing text.

rebuild search index, , should find free text queries match appropriate items. testing basic setup on instance of sc6.6, hits test info happened have lying around. if search computed column "blue" rows tagged metadata item had "blue" in name:

sitecore

Comments