Ektron solr search with smartform fields facing aproblem - ektron

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

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.

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.

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.

Related

read all document by using particular category name using alfresco search.luceneSearch or search.lib.js

Category Name
|
Geograpy (8)
Study Db (18)
i am implement my own advance search in alfresco. i need to read all files which related with particular category.
example:
if there is 20 file under geograpy, lucene query should read particular document under search key word "banana".
Further explanation -
I am using search.lib.js to search. I would like to analyze the result to find out to which category the documents belong to. For example I would like to know how many documents belong to the category under Languages and the subcategories. I experimented with the Classification API but I don't get the result I want. Any Idea how to go through the result to get the category name of each document?
is there any simple method like node.properties["cm:creator"]?
thanks
janaka
I think you should specify more your question:
Are you using cm:content or a customized content?
Are you going to search the keyword inside the content of the file? or are you going to search the keyword in a specific metadata(s)?
Do you want to create a webscript (java or javascript)?
One thing to take in consideration:
if you use +PATH:"cm:generalclassifiable/...." for the categorization in your lucene queries, the performance will be slow (following my experince)
You can use for example the next query to find all nodes at any depth below /cm:Languages:
var results = search.luceneSearch("+PATH:\"cm:generalclassifiable/cm:Languages//*\");
Take a look to this url: https://wiki.alfresco.com/wiki/Search#Path_Queries
Once you have all the elements, you can loop all, and get to which category below. Of course you need to create some counter per each category/subcategory:
for(i = 0; i < results.length; i++){
var node = results[i];
var categoryNodeRef = node.properties["cm:categories"];
var categoryDesc = categoryNodeRef.properties["cm:description"];
var categoryName = categoryNodeRef.properties["cm:name"];
}
This is not exactly the solution, but can be a useful idea to start.
Sorry if it's not what you're asking for, I have just arrived from my holidays.

Lucene.net PerFieldAnalyzerWrapper

I've read on how to use the per field analyzer wrapper, but can't get it to work with a custom analyzer of mine. I can't even get the analyzer to run the constructor, which makes me believe I'm actually calling the per field analyzer incorrectly.
Here's what I'm doing:
Create the per field analyzer:
PerFieldAnalyzerWrapper perFieldAnalyzer = new PerFieldAnalyzerWrapper(srchInfo.GetAnalyzer(true));
perFieldAnalyzer.AddAnalyzer("<special field>", dta);
Add all the fields do document as usual, including a special field that we analyze differently.
And add document using the analyzer like this:
iw.AddDocument(doc, perFieldAnalyzer);
Am I on the right track?
The problem was related to my reliance on CMSs (Kentico) built-in Lucene helper classes. Basically, using those classes you need to specify the custom analyzer at index-level through the CMS and I did not wish to do that. So I ended up using Lucene.net directly almost everywhere gaining the flexibility of using any custom analyzer I want
I also did some changes to how I structure data and ended up using the tried-and-true KeywordAnalyzer to analyze document tags. Previously I was trying to do some custom tokenization magic on comma separated values like [tag1, tag2, tag with many parts] and could not get it reliably working with multi-parted tags. I still kept that field, but started adding multiple "tag" fields to the document, each storing one tag. So now I have N "tag" fields for "N" tags, each analyzed as a keyword, meaning each tag (one word or many) is a single token.
I think I overthinked it with my initial approach.
Here is what I ended up with.
On Indexing:
KeywordAnalyzer ka = new KeywordAnalyzer();
PerFieldAnalyzerWrapper perFieldAnalyzer = new PerFieldAnalyzerWrapper(srchInfo.GetAnalyzer(true));
perFieldAnalyzer.AddAnalyzer("documenttags_t", ka);
-- Some procedure to compile all documents by reading from DB and putting into Lucene docs
foreach(var doc in docs)
{
iw.AddDocument(doc, perFieldAnalyzer);
}
On Searching:
KeywordAnalyzer ka = new KeywordAnalyzer();
PerFieldAnalyzerWrapper perFieldAnalyzer = new PerFieldAnalyzerWrapper(srchInfo.GetAnalyzer(true));
perFieldAnalyzer.AddAnalyzer("documenttags_t", ka);
string baseQuery = "documenttags_t:\"" + tagName + "\"";
Query query = _parser.Parse(baseQuery);
var results = _searcher.Search(query, sortBy)

How do you get Endeca to search on a particular target field rather than across all indexed fields?

We have an Endeca index configured across multiple fields of email content - subject and body. But we only want searches to be performed on the subject lines. Endeca is returning matches within the bodies too. How do you limit the search to the subject?
You can search a specific field or fields by specifying it (them) with the Ntk parameter.
Or if you wish to search a specific group of fields frequently you can set up an interface (also specified with the Ntk parameter), that includes that group of fields.
This is how you can do it using presentation API.
final ENEQuery query = new ENEQuery();
final DimValIdList dimValIdList = new DimValIdList("0");
query.setNavDescriptors(dimValIdList);
final ERecSearchList searches = new ERecSearchList();
final StringBuilder builder = new StringBuilder();
for(final String productId : productIds){
builder.append(productId);
builder.append(" ");
}
final ERecSearch eRecSearch = new ERecSearch("product.id", builder.toString().trim(), "mode matchany");
searches.add(eRecSearch);
query.setNavERecSearches(searches);
Please see this post for a complete example.
Use Search Interfaces in Developer Studio.
Refer - http://docs.oracle.com/cd/E28912_01/DeveloperStudio.612/pdf/DevStudioHelp.pdf#page=209

Endeca UrlENEQuery java API search

I'm currently trying to create an Endeca query using the Java API for a URLENEQuery. The current query is:
collection()/record[CONTACT_ID = "xxxxx" and SALES_OFFICE = "yyyy"]
I need it to be:
collection()/record[(CONTACT_ID = "xxxxx" or CONTACT_ID = "zzzzz") and
SALES_OFFICE = "yyyy"]
Currently this is being done with an ERecSearchList with CONTACT_ID and the string I'm trying to match in an ERecSearch object, but I'm having difficulty figuring out how to get the UrlENEQuery to generate the or in the correct fashion as I have above. Does anyone know how I can do this?
One of us is confused on multiple levels:
Let me try to explain why I am confused:
If Contact_ID and Sales_Office are different dimensions, where Contact_ID is a multi-or dimension, then you don't need to use EQL (the xpath like language) to do anything. Just select the appropriate dimension values and your navigation state will reflect the query you are trying to build with XPATH. IE CONTACT_IDs "ORed together" with SALES_OFFICE "ANDed".
If you do have to use EQL, then the only way to modify it (provided that you have to modify it from the returned results) is via string manipulation.
ERecSearchList gives you ability to use "Search Within" functionality which functions completely different from the EQL filtering, though you can achieve similar results by using tricks like searching only specified field (which would be separate from the generic search interface") I am still not sure what's the connection between ERecSearchList and the EQL expression above?
Having expressed my confusion, I think what you need to do is to use String manipulation to dynamically build the EQL expression and add it to the Query.
A code example of what you are doing would be extremely helpful as well.

How can I search Dynamics CRM using OrganizationService for a specific record?

If I know the accountId of a record I can do something like this:
Dim cols As New ColumnSet(New String() {"name",
"address1_postalcode",
"lastusedincampaign"})
Dim retrievedAccount As Account = _orgService.Retrieve("account", _accountId, cols).ToEntity(Of Account)()
But what if I don't know the accountId and instead want to search for a record based on some other factor? Say, returning all records with "John" as the first name?
You have to use the RetrieveMultiple method with a QueryExpression.
See this link for some examples
You could also use Linq to CRM, or Fetch XML.
You can use QueryExpression as explained here:
http://msdn.microsoft.com/en-us/library/gg328300.aspx.
You can write your own ConditionExpression or FetchXml for the QueryExpression.
For more complicated query I like to use FetchXml. You can do Advanced Find then download the generated FetchXml, or use any number of online tools like Fetch Xml Builder to generate it first.
Hope that helps.