Aju Mon
Aju Mon

Reputation: 235

Ektron solr search with smartform fields facing aproblem

I am working with ektron 9.

I have created a smart from,and implemented the search for smart form fields using search api. For that am using Ektron.Cms.Framework.Search.SearchManager class.It works fine when for single Xpath values.

When my smart form has multiple fields with same Xpath,the search api is returning the results of first occurrence only.

In the below example ,when i search for Book->Title using Xpath "/root/Books/Book/Title" search always return "Hai" in result.

<root>
<Books>
<Book>
<Id>1
</Id>
<Title>Hai
</Title>
<Book>
<Book>
<Id>2
</Id>
<Title>Hello
</Title>
<Book>
</Books>
</root>

How can i get "Hello" also in the result? is any separate api to handle this? Or is it possible to handle this scenario in a separate way,like by specifying like this "/root/Books/Book[id=1]/Title" ?

For more details on search please look: http://documentation.ektron.com/cms400/v85/webhelp/Navigating/Search85/APISearch.htm#Major

Upvotes: 1

Views: 876

Answers (3)

Swami PR
Swami PR

Reputation: 871

Solr supports multivalued attributes, so when indexing smartform fields they get indexed as true multivalued fields instead of a delimiter separated values as was the case with Search Server 2010/FAST 2010.

In case of multivalued fields, from the SearchResponseData you would have to use the SearchResultData returned in the following manner.

For the case of Multivalued String properties GetValue(StringMultiValuePropertyExpression) or use the indexer [StringMultiValuePropertyExpression]

For the case of Multivalued Floating point properties GetValue(DecimalMultiValuePropertyExpression) or use the indexer [DecimalMultiValuePropertyExpression]

Reference http://reference.ektron.com/developer/framework/Search/SearchResultData/

In case one doesn't use the MultiValuePropertyExpression, the API will return the first value of the set of values which is what you are seeing.

Hope this helps.

Upvotes: 0

MaxPRafferty
MaxPRafferty

Reputation: 4977

Ektron 9's solr integration has been fairly buggy for me thusfar (granted, it isn't even really out yet!), so this may actually just be a bug.

That said, does the same thing happen when you select /root/Books/Book, or does that also return only one result?

If the API is only ever returning one result, you could try making the search several times, until it comes up empty. The general pseudocode algorithm would be:

var i = 0;
List<item> allItems = new List<item>();
item myItem = select("(/root/Books/Book/Title)[0]");
while(myItem != null){
  allItems.add(myItem);
  i++;
  myItem = select("(/root/Books/Book/Title)["+i+"]");
}

keeping in mind that this is pretty crazy inefficent.

Upvotes: 0

rf_wilson
rf_wilson

Reputation: 1582

You haven't provided the code you are using so it is difficult to see where you are going wrong.

However, here is some code that will allow you to search against a SmartForm field in Ektron using Solr (or Microsoft Search Server).

This searches against a specific SmartForm in a field called "Path" - which is accessed using the XPath "/root/Path".

Ektron.Cms.Framework.Search.SearchManager sManager = new Ektron.Cms.Framework.Search.SearchManager();
AdvancedSearchCriteria searchCriteria = new AdvancedSearchCriteria();

searchCriteria.ExpressionTree = SearchContentProperty.XmlConfigId.EqualTo(YourSmartFormID);

searchCriteria.ExpressionTree &= SearchSmartFormProperty.GetStringProperty("/root/Path").EqualTo(YourPathValue);

searchCriteria.PagingInfo = new PagingInfo(10, 1);

searchCriteria.ReturnProperties = new HashSet<PropertyExpression>
{ 
    SearchContentProperty.Id, 
    SearchContentProperty.Title, 
    SearchContentProperty.QuickLink 
};

SearchResponseData response = sManager.Search(criteria);

The above example asks Search (Solr or Search Server) to return three properties: Id, Title and QuickLink.

You are likely to need to add "using" statements for Ektron.Cms.Search and Ektron.Cms.Framework.Search if you have not already.

Your best reference guide for the Ektron API is this site.

Upvotes: 0

Related Questions