Hybris 5.2
I was doing some analysis to exclude Facet Value from the Solr Search so that those products will not come in the search result.
Suppose I have lots of Color T-Shirts (Don't know how many colors) and someone told me to not show Red color T-Shirts in the search result.
There are two options which I can think
Option 1 : I have to get all the T-Shirt's colors available in the System then add a Filter in Solr Result
For Example
List<String> colorList = getAllColorsExceptRed(); //Get all colors except red
for(String color : colorList) {
searchQuery.addFacetValue("color", color);
}
This will add a filter of color SolrIndexedProperty and will solve the problem.
But I am not curious to pickup this approach.
Option 2 : Exclude Red Color property from Solr Search result rather than applying filter on all the colors.
Solr Query would be like this ..
q= *:* AND -color_string:red
//in case of multiple color exclude
q= *:* AND -color_string: (red white)
This will exclude red T-Shirt from the result. But I am not able to find which Service or Method I should choose to make a query like this.
Can anybody know how to achieve this Query (q= *:* AND -color_string:red) with service/method/searchQuery in Hybris ?
So After some hit and try, I got the Solution.
In searchQuery, we can add Raw Query as well. So I have set the query in addRawQuery method.
final String colors = "red white"; // List we can get from property file as well
searchQuery.addRawQuery("-color_string:(" + colors + ")",Operator.AND);
This makes it work!!
SolrIndexedProperty has attribute, includeInResponse if you set it as false, it will not be sent in result.
Related
I'm having an issue when using azure search for the following example data set: abc-123-456, abc-123-457, abc-123-458, etc
When making the search for abc-123-456, I'd expected to only return one results but instead getting all results containing abc-123-...
Is there some setting or way to change this behavior?
Current search settings:
TheSearchIndex.TokenFilters.Add(new EdgeNGramTokenFilter("frontEdgeNGram")
{
Side = EdgeNGramTokenFilterSide.Front,
MinGram = 3,
MaxGram = 20
});
TheSearchIndex.Analyzers.Add(new CustomAnalyzer("FrontEdgeNGram", LexicalTokenizerName.Whitespace)
{
TokenFilters =
{
TokenFilterName.Lowercase,
new TokenFilterName("frontEdgeNGram"),
TokenFilterName.Classic,
TokenFilterName.AsciiFolding
}
});
SearchOptions UsersSearchOptions = new SearchOptions
{
QueryType = SearchQueryType.Simple,
SearchMode = SearchMode.All,
};
Using azure.search.documents ver 11.1.1
Edit: Search with abc-123-456* with the asterisk gives me the one result as expected. How to get this behavior working as default?
Just to add to this..
The portal version is 2020-06-30
The sdk version we use is azure.search.documents ver 11.1.1
abc-123-456 does NOT work as expected
"abc-123-456" does NOT work as expected
"abc-123-456"* does NOT work
"abc-123-456*" does NOT work
If we append an asterisks to the end of the search text and it is not within a phrase .. it works as expected.
IE:
abc-123-456* works as expected.
(abc-123-456* | abc-123-457* ) works as expected.
Why is the asterisks required? How can we make this work within a phrase?
This is expected behavior when using the EdgeNGramTokenFilter inside the custom analyzer configuration. The text “abc-123-456” is broken into smaller tokens like “abc”, “abc-1”, “abc-12”, “abc-123”….”abc-123-456”. Check out the Analyzer API for the full list of tokens generated by a particular analyzer.
For a query - abc-123, if the default analyzer is being used, the query terms will be abc and 123 and will match all the documents that contain these terms.
The prefix query on the other hand is not analyzed and looks for documents that contain the prefix as is “abc-123”. A prefix search bypasses full-text search and looks for verbatim matches, which is why the correct result is coming back. Full-text search is over tokens in inverted indexes. Everything else (filters, fuzzy, regex, prefix/wildcard, etc.) is over verbatim strings in a separate unprocessed/internal index.
Another way can be to set only the search analyzer on the field to keyword to avoid breaking the input query.
I have Alfresco 5.2 and my task is "to get all documents with empty (one of) property", I am creating a query
searchParameters.setQuery("search +TYPE:\"ecmcndintregst:nd_int_reg_standards\" +#ecmcnddoc\\:doc_name_ru:\"\" -ASPECT:\"ecmcdict:inactive\" AND ( #ecmcnddoc\\:doc_kind_cp_ecmcdict_value:\"mek\")");
And I got all the documents thus: with either - empty and non-empty ecmcnddoc:doc_name_ru
how can I get ONLY empty ecmcnddoc:doc_name_ru ?
Thank you
please tell me what am I doing wrong? How to search solr for empty properties? When I submit +#ecmcnddoc:doc_name_ru:"" (without slash) I got all documents with ANY ecmcnddoc:doc_name_ru value :(
Thank you
i am working with applying view criteria programaticlly, till now it was fine, but when i searched with "develop and unit test" it is showing 0 records even though my table having data. iam using like operator. could any one help on this .
i have one table, having option to filter by providing select combo box list of vales, for every column when i select any thing in lov in value change listener i am applying viewcriteria programatically on table vo.
note. every thing is programatic view object only there is no point of entity, or sql
Sample Code:
DCIteratorBinding bindIterator = ADFUtils.findIterator("Tri2EWS_ETKAPIData_VO1Iterator");//Table viewObject(programatic)
Tri2EWS_ETKAPIData_VOImpl voimpl = (Tri2EWS_ETKAPIData_VOImpl) bindIterator.getViewObject();
ViewCriteria viewCriteria = voimpl.createViewCriteria();
viewCriteria.setName("MyVc");
ViewCriteriaRow viewCriteriaRow = viewCriteria.createViewCriteriaRow();
viewCriteriaRow.setOperator("ViewAttr1", "LIKE");
viewCriteriaRow.setAttribute("ViewAttr1", "stack and OverFlow");
viewCriteria.add(viewCriteriaRow);
viewCriteria.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE);
voimpl.applyViewCriteria(viewCriteria, true);
voimpl.executeQuery();
voipmpl.getRowCount();//Getting 0 here (Actually i should get 1)
Turn on debug messages for ADF BC (jbo.debugoutput) so you can see the SQL that is being generated.
This will help you figure out if the query is correctly formatted.
I have a variable color .I want to add a bq only if the variable color has red in it :
ex: I want something like this
if(color==="red"){
bq=Category:Shoes^120
}
like
bq: "if(exists(query({!v='GraphNode:cream'})),(Color:cream^120),(Color:cream^80))"
doesnt work ? any suggestions?
Assuming you want to give a multiplicative boost of 120 for documents that have red in field color and Shoes in field category, you can use the Boolean and function like this (new lines only for clarity):
{!boost b="if(and(exists(query({!v='color:red'})),
exists(query({!v='category:Shoes'}))
),120,1
)
"
}(YOUR_QUERY)
All:
Right now, I am using SOLR highlight feature, but one thing I want to ask is:
Suppose I want to search keyword fund and value:
fund AND value
And the return highlight part is like:
"highlighting": {
"blk_0019": {
"content": [
"philosophy of the <em>fund</em> – <em>value</em> and turning point. \n \n MUSA was an orphaned"
]
},
"blk_0006": {
"content": [
"Global Equities <em>Fund</em> Ltd. \n \n CONFIDENTIAL enclosed"
]
}
}
The problem is I am sure blk_0019 and blk_0006 have both fund and value(obviously I use fund AND report), because the I set hl.fragsize=100, if the fund and value located not close enough in one document, they can not be shown both in same snippet. In blk_0019, solr highlights both fund and value, but in blk_0006, only fund shown.
How can I show both matched in single snippet and just ignore text between them as ..... like in Google
Also some small questions are:
[1] How to specify to search capitalized only word like Hello HELLO
in Solr?
[2] How to search All-capital AND(All-capital "AND" will be consider as logical operator)
Thanks
It depends on the highlighter you are using. For the Standard Highlighter you can set hl.snippets=5 for instance (default is 1). Then you'll get 5 snippets/fragments (at most), each with a maximum length of hl.fragsize.
They're returned as multiple values, so you'll need to join them yourself (using "..." for instance).