Gravatar for sekhar.karanam@gmail.com

Question by sekharitc, Feb 16, 2015 11:52 AM

Coveo Search box+Sitecore

Hi, I am using Coveo search in my sitecore portal .My portal has different language versions.

in search auto select text box i am getting results even i don't have particular language version.

Ex: i am having one content item which has only english version.But if search from japanies version site i am getting english versioned item details.How to restrict this.Please help me

Regards, Nagasekhar

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Feb 16, 2015 11:55 AM

Which Coveo product do you use? Coveo for Sitecore, Coveo for Salesforce, Coveo .Net Front-end?

Gravatar for sekhar.karanam@gmail.com

Comment by sekharitc, Feb 16, 2015 12:00 PM

Coveo for Sitecore

2 Replies
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Feb 16, 2015 12:10 PM

In Coveo for Sitecore, the default bahavior of a Coveo Search component is to display all the results in all languages. However, there is an option in the Coveo Search component properties to filter out results in a language other than the current item (the search page item) language. See the "Understanding the Coveo Search Component's Properties" page for more information.

Gravatar for sekhar.karanam@gmail.com

Comment by sekharitc, Feb 16, 2015 12:18 PM

H i I will go with this property..Can u guide me where can i set this settig

Filter results on the current context language Whether to return the version of a document in the results list that matches the current language. For example, if the current language is English, then only the English version of documents will be in the results list. This option is disabled by default

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Feb 16, 2015 12:34 PM

All of the settings listed on this page are located in the Coveo Search component properties dialog.

  1. Open your search page in the Sitecore Page Editor.
  2. Click on the Coveo Search component. A floating bar will be displayed with various icons.
  3. Click on the first icon to open the properties dialog.
  4. Locate the "Filter results on the current context language" property.
  5. Check the check box next to the property.
  6. Click the OK button.
  7. The Coveo Search component will automatically update to reflect your changes.
  8. If satisfied with the result, save your page.
Gravatar for sekhar.karanam@gmail.com

Comment by sekharitc, Feb 16, 2015 12:54 PM

But we have only Search Autofill text box in my home page which is sublayout. in this scenario how can i set

Gravatar for sekhar.karanam@gmail.com

Comment by sekharitc, Feb 16, 2015 12:59 PM

And also i need only specific language version items in that textbox

Gravatar for sekhar.karanam@gmail.com

Comment by sekharitc, Feb 16, 2015 1:00 PM

when i search

Gravatar for sekhar.karanam@gmail.com

Comment by sekharitc, Feb 16, 2015 1:31 PM

Sorry my question looks wrong. My question is how to restrict other language items in Auto fill textbox while searching items. this we can hide items

Gravatar for sekhar.karanam@gmail.com

Comment by sekharitc, Feb 16, 2015 1:33 PM

We not even want to search other language versions when we are in particular langue site

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Feb 16, 2015 2:13 PM

By default, the Coveo Search Box component doesn't allow the "autofill/auto select" behavior that you refer to. Can you give me the link to the procedure you used to get this functionality please? It will help me to understand your use case and answer your question precisely. Thanks.

Gravatar for sekhar.karanam@gmail.com

Answer by sekharitc, Feb 16, 2015 11:14 PM

<script type="text/javascript">
    var headerSearchPage = "<%=ABC.Business.DomainContext.Site.SearchPagePath%>"
    var pathField = "<%= Coveo.UI.SitecoreUtilities.ToCoveoFieldName("_Path") %>";

    $(function () {
        Coveo.Rest.SearchEndpoint.endpoints.default = new Coveo.Rest.SearchEndpoint({
            restUri: "/Coveo/Rest/",
            useJsonp: true
        });

        var searchInterface = $("#msearchbox");
        searchInterface.on("afterInitialization", function () {
            searchInterface.on("newQuery", function (e, args) {
                var currentKeyword = searchInterface.coveo("state", "q");
                if (currentKeyword != "") {
                    window.location.href = headerSearchPage + "#q=" + encodeURIComponent(currentKeyword)
                }
            })
        })

        $('#msearchbox').coveo('init', {
            SearchInterface: {
                autoTriggerQuery: false,
                hideUntilFirstQuery: false,
                enableHistory: false
            },
            TopFieldSuggestions: {
                queryOverride: pathField + "=A15E87645HJNGFRTL7D9440D3B30CD"
            }
        });
    });
</script>

<div id="msearchbox" class="search-box CoveoSearchInterface">
    <span class="CoveoTopFieldSuggestions"
        data-field="<%= Coveo.UI.SitecoreUtilities.ToCoveoFieldName("Auto Suggestion Keyword") %>"
        data-header-title="Suggested Queries"></span>

    <div class="CoveoSearchBox" data-activate-omnibox="true"></div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $("#msearchbox :text").attr("placeholder", "<%= Sitecore.Globalization.Translate.Text("Search")%>");
        $("#msearchbox :text").attr("maxlength", "250");
    });
</script>
Gravatar for sekhar.karanam@gmail.com

Comment by sekharitc, Feb 16, 2015 11:15 PM

i have my search box as a metioned code

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Feb 17, 2015 9:20 AM

Ok, you seem to have used the Coveo procedure to have query suggestions in your search box (see Add Query Suggestions to Your Search Box).

Can you give me the value of the "Field Name" field of your "Auto Suggestion Keyword" Facet as it appears at step 5 of the procedure above please? It will allow me to understand your setup and give you the best answer.

Thank you.

Gravatar for sekhar.karanam@gmail.com

Comment by sekharitc, Mar 3, 2015 2:41 AM

Hi ,

Thank you for your reply

below is the FiledName.

fautoz32xsuggestionz32xkeyword76838.

Thanks

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Mar 3, 2015 10:29 AM

The "Field Name" field should not be decorated at this step. Coveo for Sitecore will take care of translating the field name correctly based on the Sitecore context database at query time. The correct "Field Name" field value should be "auto suggestion keyword" as in the documentation.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Mar 3, 2015 10:35 AM

These suggestions are based on the items you created at step 7 of the tutorial. If you created different language versions of your suggestions in Sitecore you could use the data-query-override attribute of the JS Search TopFieldSuggestions Component and set it to something like this:

data-query-override='<%= Coveo.UI.SitecoreUtilities.ToCoveoFieldName("_language") %>=="<%= Sitecore.Context.Language %>"'
Gravatar for sekhar.karanam@gmail.com

Comment by sekharitc, Mar 5, 2015 1:55 AM

Thanks ..It worked for me

Ask a question