Category Archives: autocomplete

Apache Solr Autocomplete: Error 500 [on hold]

I install and activate the Apache Solr modules: view, search, autocomplete, etc... I configure the minimum of word indexed 3. When I write the 3 letters in search box, the Request URL (my_website/apachesolr_autocomplete_callback/apachesolr_search_page%3Ataxonomy_search?term=aaa) returns Status Code:500 Service unavailable (with message). in the Preview tab, a message display Exception : HTTP 403; Forbidden: Forbidden dans DrupalApacheSolrService->checkResponse() (ligne 455 dans path/my_project/modules/contrib/apachesolr/Drupal_Apache_Solr_Service.php). Can you help me ?

Google places API autocomplete work when accessing site with IP address but not when accessing domain name

This is a strange request, please don't be mad.

I have developed a web-site using LAMP, based on Laravel 5.2. I have tested on my home server and works good. Tested on a sub-domain on a production server and works 100%. I made a new server and loaded the site and tested the IP address and it works 100%. I then linked the domain name to the site and everything works except the google places lookup.

Below is a screen print of the IP vs. the domain name: http://139.59.164.105 vs. http://www.waste2dust.com

When on www.waste2dust.com, there appears no drop-down, when typing in an address, in the address field, under the household section. When on 139.59.164.105, the drop-down does appear, according to what the user typed. To make matters more interesting, when you type a list on 139... and then type the same list on waste... it works to the point where you typed it on 139.

I have tested this on windows, mac and ios. I have used chrome, firefox, edge and safari. The problem remains the same.

The domain name is resisted with company x, but is routed through company Y, using an alias for www.waste2dust.com. Company x DNS points to 139.59.164.105 and company Y points to 139.59.164.105. I using company Y for the mail service of the waste2dust e-mails.

When using www.waste2dust.com, using firefox, I see the loop-up request complete and the data is returned from google to the browser. The .pac-container class (part of the google places API) however does not activate to show the drop-down list of places, like on the other site. The style{ display: none;} stays active.

<div style="width: 356px; position: absolute; left: 916px; top: 345px; display: none;" class="pac-container pac-logo"></div>

It does not add the "pac-item" when typing happens.

I know this is very specific and for my own site, but I don't know where to find the answer. Any help will be greatly appreciated.

Solr autocomplete function with numbers

I am currently working with apache solr and I implemented an autocomplete function for a search text field. It works pretty well with letters, but the problem I have now is with numbers. Numbers will not be autocomplete, despite there are in my index. Does anyone know this kind of problem?

Heres my schema.xml:

    <fieldType name="suggest_de" class="solr.TextField" positionIncrementGap="100">
                <analyzer type="index">
                    <tokenizer class="solr.KeywordTokenizerFactory" />
                    <filter class="solr.LowerCaseFilterFactory" />
                    <filter class="solr.WordDelimiterFilterFactory"
                            splitOnCaseChange="0" splitOnNumerics="0"
                            generateWordParts="1" generateNumberParts="0" catenateWords="0"
                            catenateNumbers="1" catenateAll="0" preserveOriginal="1"/>
                    <filter class="de.hybris.platform.solrfacetsearch.ysolr.synonyms.HybrisSynonymFilterFactory" ignoreCase="true" synonyms="de" coreName="${solr.core.name}"/>
                    <filter class="de.hybris.platform.solrfacetsearch.ysolr.stopwords.HybrisStopWordsFilterFactory" ignoreCase="true" lang="de" coreName="${solr.core.name}"/>
                    <filter class="solr.StopFilterFactory" words="solr/embedded/conf/stopwords_de.txt" ignoreCase="true" />
                    <filter class="solr.TrimFilterFactory" />
                    <filter class="solr.RemoveDuplicatesTokenFilterFactory" />
                </analyzer>
                <analyzer type="query">
                    <tokenizer class="solr.KeywordTokenizerFactory" />
                    <filter class="solr.LowerCaseFilterFactory" />
                </analyzer>
            </fieldType>

<field name="autosuggest" type="string" indexed="true" stored="true" multiValued="true" />
        <field name="autosuggest_de" type="suggest_de" indexed="true" stored="true" multiValued="true" />

        <copyField source="autosuggest" dest="autosuggest_de" />

and my solrconfig.xml:

<requestHandler name="/suggest" class="solr.SearchHandler">
        <lst name="defaults">
            <str name="spellcheck">true</str>
            <str name="spellcheck.dictionary">default</str>
            <str name="spellcheck.onlyMorePopular">true</str>
            <str name="spellcheck.count">10</str>
            <str name="spellcheck.collate">true</str>
            <str name="mm">100%</str>
        </lst>
        <arr name="components">
            <str>suggest</str>
        </arr>
    </requestHandler>

<searchComponent name="suggest" class="solr.SpellCheckComponent">
        <str name="queryAnalyzerFieldType">autosuggest</str>
        <lst name="spellchecker">
            <str name="name">default</str>
            <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
            <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
            <str name="field">autosuggest_de</str>
            <str name="buildOnOptimize">true</str>
            <str name="accuracy">0.35</str>
            <str name="characterEncoding">UTF-8</str>
        </lst>
        <lst name="spellchecker">
            <str name="name">de</str>
            <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
            <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
            <str name="field">autosuggest_de</str>
            <str name="buildOnOptimize">true</str>
            <str name="accuracy">0.35</str>
            <str name="characterEncoding">UTF-8</str>
        </lst>
    </searchComponent>

As I said there are no problems with letters, but everything starting with numbers is not returned in queries.

jquery Autocomplete source php htaccess issue

I am in the middle of making a CMS as a project.

I want to be able to search a user and it autocomplete with results from a database.

I have got this working on a single page.

But my CMS doesnt seem to want to allow it to work.

The structure I am using is: admin -index.php -pages -moduals.php pages -pages -page.php index.php

in the admin and main index files I have setup an include system.

so if you goto domain.tld/admin/user it will actually take you to admin/index.php?page=user

the htaccess file looks like this:

RewriteEngine on
RewriteRule ^admin/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ admin/?page=$1&task=$2&id=$3
RewriteRule ^admin/([^/\.]+)/([^/\.]+)/?$ admin/?page=$1&id=$2
RewriteRule ^admin/([^/\.]+)/?$ admin/?page=$1
RewriteRule ^admin/ admin/index.php
RewriteRule ^profile/([^/\.]+)/?$ index.php?page=profile&name=$1
RewriteRule ^hardware/([^/\.]+)/?$ index.php?page=hardware&name=$1
RewriteRule ^activate/([^/\.]+)/?$ index.php?page=activate&akey=$1
RewriteRule ^([^/\.]+)/?$ index.php?page=$1
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&id=$2
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&id=$2&title=$3


<Files ~ "^\.ht">
 Order allow,deny
 Deny from all
 Satisfy All
</Files>

<IfModule mod_deflate.c>
    # Compress HTML, plain text, CSS and JavaScript
    AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/x-javascript

    # Avoid problems in problematic browsers
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/x-icon "access plus 2 weeks"
    ExpiresByType application/x-javascript "access plus 2 weeks"
    ExpiresByType text/javascript "access plus 2 weeks"
    ExpiresByType text/css "access plus 2 weeks"
    ExpiresByType image/gif "access plus 2 weeks"
    ExpiresByType image/png "access plus 2 weeks"
    ExpiresByType image/jpeg "access plus 2 weeks"
    ExpiresByType application/pdf "access plus 2 weeks"
</IfModule>

the code for the page which I am using the autocomplete file is:

    <form action='' method='post'>
        <p><label>username:</label><input type='text' name='username' value='' class='auto'></p>
    </form>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>    
<script type="text/javascript">
$(function() {

    //autocomplete
    $(".auto").autocomplete({
        source: "jquser.php",
        minLength: 2
    });                

});
</script>

the file jquser.php is in the same file as that which is teams.php

The jquser.php file looks like this:

<?
define('DB_SERVER', 'XXXXX');
define('DB_USER', 'XXXXX');
define('DB_PASSWORD', 'XXXXX');
define('DB_NAME', 'XXXX');


if (isset($_GET['term'])){
    $return_arr = array();

    try {
        $conn = new PDO("mysql:host=".DB_SERVER.";port=8889;dbname=".DB_NAME, DB_USER, DB_PASSWORD);
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        $stmt = $conn->prepare('SELECT username FROM user WHERE username LIKE :term');
        $stmt->execute(array('term' => '%'.$_GET['term'].'%'));

        while($row = $stmt->fetch()) {
            $return_arr[] =  $row['username'];
        }

    } catch(PDOException $e) {
        echo 'ERROR: ' . $e->getMessage();
    }


    /* Toss back results as json encoded array. */
    echo json_encode($return_arr);
}

?>

Now if i delete the htaccess file it works, it just doesnt work with the htaccess file, I guess its the rewrite rule.

Can someone help me, its probably simple but for some reason my simpleton brain cant handle it.

I am sorry for the long post I wanted to give as much information as possible.

Thanks in advance for your help.

How to make solr suggestions work on existing instance

I have been trying to implement auto-complete facility. I tried few methods, but it seems it doesn't work. Like in this, I created a copyfield suggest_phrase as dest and my existing article field as source. But I believe, getting it done requires reindex.

I want autocomplete based on an existing field whose type is default "text_general".

Solr now has an suggest component (from 4.7.1), as pointed here, but that too doesn't seem to work for me when I try to apply on my existing fields. What else I need to do besides changing field name to existing field that contains the data ?

I need auto-complete of phrases.

I have solr data in several GBs and I am trying to avoid reindex if possible. But if there is no way, I will go for it.