Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • vaibhav 119 posts 139 karma points
    Aug 22, 2011 @ 14:31
    vaibhav
    0

    Lucene Search for multilingual site

    Hello,

    I have my website in two lenguages i.e English & danish

    Like this....

    EN

    >page1

    >page2

    >page3

    DN

    >Page1

    >Page2

    >Page3

    both are inside the same domain.

    i.e. for english site i use www.xyz.com/en  & for danish site i use www.xyz.com/dn

    I have problems while searching ...

    I have created the search control

    when i search for some word it searches in both the websites & shows the results on the results page of the english site which i dont want....

    (search control is usercontrol made by me)

    I want that if i search in english site then results only from english site should be shown on the results page which is in side english site & if i search in danish site then results only from english site should be shown on the results page which is in side danish site.

  • vaibhav 119 posts 139 karma points
    Aug 22, 2011 @ 15:11
    vaibhav
    0

    Hello,

    I have my website in two lenguages i.e English & danish

    Like this....

    EN

    >page1

    >page2

    >page3

    DK

    >Page1

    >Page2

    >Page3

    both are inside the same domain.

    i.e. for english site i use www.xyz.com/en  & for danish site i use www.xyz.com/dn

    I have problems while searching ...

    I have created the search control

    when i search for some word it searches in both the websites & shows the results on the results page of the english site which i dont want....

    (search control is usercontrol made by me)

    I want that if i search in english site then results only from english site should be shown on the results page which is in side english site & if i search in danish site then results only from danish site should be shown on the results page which is in side danish site.

    I think i have to change the indexing but dont know wat to change ....

    I also have one more problem....

    When i search then always result page of the english site is shown ...but i have created result page for both english & danish sites.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 22, 2011 @ 15:15
    Dirk De Grave
    0

    you could create two indexes, one for each language on your site and use the correct corresponding searcer when performing your search!

    For example (in ExamineIndex.config):

    <IndexSet SetName="Language1IndexSet" IndexPath="~/App_Data/ExamineIndexes/Language1/" IndexParentId="id1">
        <IndexAttributeFields />
        <IndexUserFields />
        <IncludeNodeTypes />
        <ExcludeNodeTypes />
      </IndexSet>
      <IndexSet SetName="Language2IndexSet" IndexPath="~/App_Data/ExamineIndexes/Language2/" IndexParentId="id2">
        <IndexAttributeFields />
        <IndexUserFields />
        <IncludeNodeTypes />
        <ExcludeNodeTypes />
      </IndexSet>

    Of course, also have to provide index providers and search provider in examineSettings.config. Make sure to use the naming conventions for both indexer and searcher.

     

    Cheers,

    /Dirk

  • vaibhav 119 posts 139 karma points
    Aug 23, 2011 @ 12:01
    vaibhav
    0

    I really dont know how to create different indexes for different languages.... also how to use there searcher while searching ...

    right now for my english site i am using default indixing provided in umbraco ....

    I have creted one usercontrol which passes the word to be searched to xslt & then xslt displays the result ....my xslt is something like this.....

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:examine="urn:examine"
      xmlns:umbraco.library="urn:umbraco.library"
      xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon"
      xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes"
      xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath"
      xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"
      xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
      xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml examine umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


      <xsl:output method="xml" omit-xml-declaration="yes"/>

      <xsl:param name="currentPage"/>

      <!-- Get the search term from the query string-->
      <xsl:variable name="searchTerm" select="umbraco.library:RequestQueryString('s')" />

      <xsl:template match="/">

        <!-- Check if there's a search term to search on-->
        <xsl:if test="string-length($searchTerm) > 0">

          
          <!-- Get the search results from examine -->
          <!--************************ THIS IS WHERE THE MAGIC HAPPENS *****************************-->
                
          <xsl:variable name="results" select="examine:Search($searchTerm)"/>

          <!--************************ END OF MAGIC ************************************************-->
          
          
          <p>
           &nbsp;&nbsp;&nbsp;&nbsp; Search text:&nbsp;<b>
              <u>
                <xsl:value-of select="$searchTerm"/>
              </u>
            </b>&nbsp;&nbsp;<i>
              <b>
                <xsl:value-of select="count($results//node)"/>
              </b>&nbsp;result(s)
            </i>
          </p>

          <xsl:if test="count($results//node) > 0">

            <!-- there is a result, so show them in the order of best score -->

            <ul>
              <xsl:for-each select="$results//node">
                <xsl:sort select="number(@score)" order="descending"/>

                <li>

                  <!-- add alternating colors -->
    <!--              <xsl:choose>
                    <xsl:when test="position() mod 2 ">
                      <xsl:attribute name="class">secondary-a-5</xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:attribute name="class">secondary-b-4</xsl:attribute>
                    </xsl:otherwise>
                  </xsl:choose>  -->

                  <!-- Get the URL -->
                  <xsl:variable name="url" select="concat('http://', umbraco.library:RequestServerVariables('SERVER_NAME') , ':' , umbraco.library:RequestServerVariables('SERVER_PORT') ,umbraco.library:NiceUrl(./data[@alias='id']))" />

                  <!-- Create the search result line item-->
          <!--        <a href="{$url}">
                    <span class="title">
                      <xsl:value-of select="./data[@alias='nodeName']"/>
                    </span>
                    <span class="link">
                      <xsl:value-of select="$url"/>
                    </span>
                    <span class="score">
                      <xsl:value-of select="./@score"/>
                    </span>
                  </a> -->
                  <div>
                    <div id="searchTitle"><a href="{$url}"><xsl:value-of select="./data[@alias='nodeName']"/></a> </div> <div id="searchTime"> <!-- <xsl:value-of select="./@score"/> --> </div>
                  </div>
                  <xsl:value-of select="umbraco.library:TruncateString(./data[@alias='content'], 360,'...')" disable-output-escaping="yes"/>
                  <!--<xsl:value-of select = "./data[@alias='content']"/> -->
                  <div id="searchLink">
                    <a href="{$url}"><xsl:value-of select="$url"/></a>
                  </div>
                </li>

              </xsl:for-each>
            </ul>
          </xsl:if>
        </xsl:if>
      </xsl:template>

    </xsl:stylesheet>

  • vaibhav 119 posts 139 karma points
    Aug 24, 2011 @ 09:57
    vaibhav
    0

    I have created indexes for my two languages like this ...

    <IndexSet SetName="ENIndexSet" IndexPath="~/App_Data/ExamineIndexes/EN/" IndexParentId="1165">
    <IndexAttributeFields>
    <add Name="id" />
    <add Name="nodeName" />
    <add Name="updateDate" />
    <add Name="writerName" />
    <add Name="path" />
    <add Name="nodeTypeAlias" />
    <add Name="parentID" />
    </IndexAttributeFields>
    <IndexUserFields />
    <IncludeNodeTypes />
    <ExcludeNodeTypes />
    </IndexSet>

    <IndexSet SetName="DKIndexSet" IndexPath="~/App_Data/ExamineIndexes/DK/" IndexParentId="1624">
    <IndexAttributeFields>
    <add Name="id" />
    <add Name="nodeName" />
    <add Name="updateDate" />
    <add Name="writerName" />
    <add Name="path" />
    <add Name="nodeTypeAlias" />
    <add Name="parentID" />
    </IndexAttributeFields>
    <IndexUserFields />
    <IncludeNodeTypes />
    <ExcludeNodeTypes />
    </IndexSet>


    also the provider & searcher are like this ...

      <add name="ENIndexer" type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine"
    indexSet="ENIndexSet"
    supportUnpublished="false"
    supportProtected="true"
    interval="10"
    analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>

    <add name="DKIndexer" type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine"
    indexSet="DKIndexSet"
    supportUnpublished="false"
    supportProtected="true"
    interval="10"
    analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>



           <add name="ENSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" indexSet="ENIndexSet"
    analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcards="true"/>

    <add name="DKSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" indexSet="DKIndexSet"
    analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcards="true"/>

    now can any one help me for searching the data as i dont know how to use this searcher while searching  ....

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 24, 2011 @ 10:28
    Ismail Mayat
    0

    vaibhav,

    You need to use the examine search method with signature SearchContentOnly(string searchText, bool useWildcards, string providerName) and pass in the provider eg ENSearcher

    Regards

    Ismail


  • vaibhav 119 posts 139 karma points
    Aug 24, 2011 @ 10:59
    vaibhav
    0

    Hi Ismail ,

    Can you tell me how can i do this with xslt ..which i have posted above .... or have to do this in the cs file of the usercontrol which i am using.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 24, 2011 @ 11:08
    Ismail Mayat
    0

    In your xslt you have line

    <xsl:variablename="results"select="examine:Search($searchTerm)"/>

    You need to call the method examine:SearchContentOnly($searchTerm,true(),'ENSearcher') if you are doing english only search and change to DKSearcher if DK.

     

  • vaibhav 119 posts 139 karma points
    Aug 24, 2011 @ 11:35
    vaibhav
    0

    getting error as "Error parsing XSLT file: \xslt\SearchResults.xslt" ...

    may be it is not able to find method ...SearchContentOnly ....

    how to solve this ....

  • vaibhav 119 posts 139 karma points
    Aug 25, 2011 @ 11:00
    vaibhav
    0

    hi,

    I solved the problem ....

    i just changed

    xmlns:examine="urn:examine"
    with
    xmlns:umbraco.examine="urn:umbraco.examine"

    &
    exclude-result-prefixes="msxml examine umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    with
    exclude-result-prefixes="msxml umbraco.examine umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">



    after that i used this ...

    <xsl:variablename="results"select="umbraco.examine:SearchContentOnly($searchTerm,true(),'ENSearcher')"/>
    insted of 
    <xsl:variablename="results"select="examine:Search($searchTerm)"/>
    

    thanks....Dirk & Ismail

  • raju 3 posts 23 karma points
    Aug 10, 2012 @ 09:44
    raju
    0

    Lucene search is not working for Chinese langauge character , can anybody help me in this ?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 10, 2012 @ 10:46
Please Sign in or register to post replies

Write your reply to:

Draft