Git Product home page Git Product logo

ajax-solr's Introduction

AJAX Solr

AJAX Solr is a JavaScript library for creating user interfaces to Apache Solr.

Get an offline copy of the documentation, examples, and tutorial files by downloading either a zipball or tarball.

Documentation is generated by JsDoc Toolkit with the command:

java -jar jsrun.jar app/run.js -a -p -r=3 -t=templates/jsdoc /path/to/library/

ajax-solr's People

Contributors

daniel15 avatar dsmiley avatar jebailey avatar loganfsmyth avatar seralf avatar wucris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ajax-solr's Issues

PagerWidget.js / ParameterHistoryStore.js / history.js IE Issue

I am using the ParameterHistoryStore.js widget and history.js (from https://github.com/browserstate/history.js) in order for the back button to work with AJAX Solr. This works perfect in Chrome, but in IE I have a strange problem.

IE works fine when entering different search terms. So if I enter:
Term 1 and search
Term 2 and search
Term 3 and search
Term 4 and search

And then I can hit the back button 3 times and each time it goes back to the previous search just fine.

But when using the back button after advancing using the pager widget (PagerWidget.js), it behaves very strange.

I start out on page 1 and advance to page 2, 3, and then 4. If I hit the back button the first time, it works fine. But then after that, it does not work right. I have to hit it 6 times in order for the previous page to display. And then 6 times again for the previous page again, etc.

Here is what I'm seeing in the URL:

< Initial page >
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*%3A*&_suid=140122509063205775955044440773

< Advance to page 2 >
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*%3A*&start=10&_suid=140122512196008766649033558307

< Advance to page 3 >
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*%3A*&start=20&_suid=140122509688209614022226356151

< Advance to page 4 >
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*%3A*&start=30&_suid=140122512417908545902735430961

< back > (this is correct ... goes back to page 3)
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*%3A*&start=20&_suid=140122509688209614022226356151

< back > (this stays on page 3)
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*%25253A*&start=20&_suid=1401225907440003541689561371841

< back > (this stays on page 3)
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*:*&start=20&_suid=140122590559604237124418511937

< back > (this stays on page 3)
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*%3A*&start=20&_suid=140122590559604237124418511937

< back > (this stays on page 3)
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*%253A*&start=20&_suid=140122590559604237124418511937

< back > (this stays on page 3)
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*:*&start=20&_suid=140122509688209614022226356151

< back > (this is correct ... finally goes back to page 2)
http://intertestnyc.fgic.com/search/index.jsp#index.jsp?q=*%3A*&start=10&_suid=140122512196008766649033558307

So going back to page 2 took hitting the back button 6 times.
When I hit it 6 more times, it finally goes back to page 1.

Any ideas on what's going on here? Thanks so much!

Not able to fetch reuters data

Hello,
I am unable to fetch reuters' data from AJAX SOLR. I downloaded AJAX SOLR and clicked on index.html. It's not fetching reuters' data right now.

Add a method that runs doRequest(0)

It's come up on the mailing list that doRequest is very frequently called with the argument 0 for the start parameter, and that there should be a method that omits this argument. The only issue here is what to call that method, since implementing it is trivial.

[Reuters tutorial] No unautocomplete() method anymore

The jQuery plugin autocomplete is deprecated and not developed anymore. Its successor is part of the jQuery UI project and does not have the unautocomplete() method. But the tutorials, on step 7, specifies:

We must unautocomplete() to prevent a memory leak. unautocomplete() removes keydown bindings, so we must bind keydown in afterRequest instead of init.

Do we still need to removes bindings with the new version of autocomplete? And if yes, do you have a workaround to propose?

Websolr integration

After integrating this script with websolr (https://websolr.com) I found and issue, now I don't know if it is a websolr configuration or a script issue.
When searching for text, not using auto completion, I don't get any results back.
The q parameter is set correctly and sent, but the only way I managed to make this work was to add the title as a facet and send the request with q = (multiply sign):(multiply sign) and in facet title:test

Here is the repository: https://github.com/front/ajax-solr-proto

Problem with ParameterStore instances when performing requests and only udating some widgets

Hello,

I have a results page with different widgets (tagclouds, navigation, results...)

The result content is an html table displaying some solr fields. I want to display some detail content when a double click is performed in one row.

For this purpose i followed this example

https://github.com/evolvingweb/ajax-solr/wiki/Tutorial%3A-Send-a-Solr-request-without-updating-widgets

The code to make rows selectable is the following

$(table).selectable({
                        filter:'tr',
                        selected: function(event, ui){

                            var newstore = new AjaxSolr.ParameterStore();

                            newstore.addByValue('fq', 'systemname' + ':' + ui.selected.id);
                            newstore.addByValue('q', '*:*');
                            newstore.addByValue('group', true);
                            newstore.addByValue('group.field', ['element_type']);
                            newstore.addByValue('group.ngroups', true);
                            newstore.addByValue('group.limit', 1000);
                            newstore.addByValue('json.nl', 'map');
                            newstore.addByValue('sort', 'systemname asc');

                            self.manager.executeRequest('select', newstore.string(), function (data) {
                                self.manager.widgets['detailResult'].afterRequest(data);
                            });



                        }
                    });

self.manager.widgets['detailResult'] is a custom widget with a method that process data parameter instead process manager.response value

afterRequest: function (data) {
        if (data){ 
            $(this.target).empty();

            for (var i = 0, l = data.grouped[this.group_field].groups.length; i < l; i++) {
                var table =  $('<table class="confluenceTable" style="margin-top:0px"><tbody></tbody></table>');
                $(this.target).append(table);
                $(table).append('<tr><th class="confluenceTh">Name</th><th class="confluenceTh">Type</th><th class="confluenceTh">Arch</th><th class="confluenceTh">Date</th><th class="confluenceTh">Time</th><th class="confluenceTh">Lic Exp</th><th class="confluenceTh">Message Srv</th><th class="confluenceTh">Installation Number</th><th class="confluenceTh">TMS Domain</th></tr>');


                      for (var j = 0, m = data.grouped[this.group_field].groups[i].doclist.docs.length; j < m; j++) {

                          var doc = data.grouped[this.group_field].groups[i].doclist.docs[j];
                          var first = j==0;
                          if (data.grouped[this.group_field].groups[i].doclist.docs.length>1){
                             $(table).append(this.template(doc,data.grouped[this.group_field].groups[i].doclist.docs.length,first));
                          }
                          else  $(table).append(this.template(doc));


                          var items = [];
                          items = items.concat(this.facetLinks('architecture', doc.architecture));
                          items = items.concat(this.facetLinks('systemtype', doc.systemtype));
                          items = items.concat(this.facetLinks('element_type', doc.element_type));
                          var $links = $('#links_' + doc.id);
                          $links.empty();
                          for (var k = 0, itemsL = items.length; k < itemsL; k++) {
                            $links.append($('<li></li>').append(items[k]));
                          }
                      }
            }
        }

The problem i'm experiencing resides the block

var newstore = new AjaxSolr.ParameterStore();

                            newstore.addByValue('fq', 'systemname' + ':' + ui.selected.id);
                            newstore.addByValue('q', '*:*');
                            newstore.addByValue('group', true);
                            newstore.addByValue('group.field', ['element_type']);
                            newstore.addByValue('group.ngroups', true);
                            newstore.addByValue('group.limit', 1000);
                            newstore.addByValue('json.nl', 'map');
                            newstore.addByValue('sort', 'systemname asc');

                            self.manager.executeRequest('select', newstore.string(), function (data) {
                                self.manager.widgets['detailResult'].afterRequest(data);
                            });

where the new ParameterStore seems to see the same to the manager.store

  • After instantiation the values are the same than manager.store ones
  • When i modify newstore, further calls to manager.doRequest in the default way seems to have the parameters specified for newstore ...

Any idea???

Ajax-Solr not work after change jquery.min.js 1.7.2 to newer version (1.11.2)

I used an Ajax-solr to display my solr cores. With an old jquery version (1.7.2) everything works properly. Now i should integrate my part with another code, where i should use the version of jquery - 1.11.2. As soon as i changed the library version i get following mistake

Uncaught Error: Syntax error, unrecognized expression: http://10.46.3.100:8982/solr/RMRB/
at Function.fb.error (jquery.min.js:2)
at fb.tokenize (jquery.min.js:2)
at fb.select (jquery.min.js:2)
at Function.fb [as find] (jquery.min.js:2)
at m.fn.init.find (jquery.min.js:2)
at new m.fn.init (jquery.min.js:2)
at m (jquery.min.js:2)
at child.afterRequest (ResultWidget.js:41)
at child.handleResponse (AbstractManager.js:145)
at Object.handler (Manager.jquery.js:23)

auto widget creation based on return factes

For dynamic behavivour it would be great if its detected what widget need to be rendered for returned facets of request.
This is useful if you have only some know facets and dynamic fields will be available via a detailed search tab where this addiotional factes can be showed and choosen

Not able to show the Calendar widget

I have followed the steps....but not able to show the calendar widget successfully.....

Whenever I am adding 'facet.date': 'date',
'facet.date.start': '1987-02-26T00:00:00.000Z/DAY',
'facet.date.end': '1987-10-20T00:00:00.000Z/DAY+1DAY',
'facet.date.gap': '+1DAY',

in reuters.js the code breaks

ParameterYUIStore conflicts with Autocomplete Widget

When clicking on results in the autocomplete, sometimes it does not hide and it stays there. I noticed that after I put in ParameterYUIStore, that afterRequest runs 2 times when you select a result in the autocomplete (it only runs 1 time before I put in ParameterYUIStore).

Capturing Errors

If a search entry produces an error in Solr: ie


< lst name="error" >
  < str name="msg" > org.apache.solr.earch.SyntaxError: undefined field / > < str />
  < int name="code" > 400  < / >
< /lst >

How can we get modify ajax-solr to have this error message returned? Currently, there is no data in the Manager.response object when an error occurs.

Autocomplete widget when facet value contain space

Hi,

I just ran into this problem. When the facet.value variable contain space, the Autocomplete widget don't formatted it correctly before sending the request.

if (self.manager.store.addByValue('fq', facet.field + ':' + facet.value))

If I used this little validation function in the AbstractFacetWidget, it works!

fq: function (value, exclude) {
// If the field value has a space or a colon in it, wrap it in quotes,
// unless it is a range query.
if (value.match(/[ :]/) && !value.match(/[[{]\S+ TO \S+[]}]/)) {
value = '"' + value + '"';
}
return (exclude ? '-' : '') + this.field + ':' + value;
}

Thanks for this great piece of software, it's really helping me out

MartinO

A simple how to to get an example working

How would one go about setting up the the example? Any how to wiki page?

Interesting project and I am sure you have some "how to" docs in your plan just wondering if it can be a bit earlier :)

Cheers

Make the current class system compatible with CoffeeScript's

If not possible to make compatible, maybe replace the class system with CoffeeScript's? (I forget if the current solution supports super, but CoffeeScript's does.)

Update: Replacement would break backwards-compatibility, which is a bigger disadvantage than whatever advantage using CoffeeScript's class system has.

AjaxSolr.ParameterHistoryStore does not work out of the box

Hi JP,
Was messing around with different ParameterStore implementations and noticed that ParameterHistoryStore does not work out of the box.
Regardless of the problems I am getting (which BTW seem to be history.js specific), the way we use this library needs to be updated anyway.
History.js is now maintained by browserstate and can be located below
https://github.com/browserstate/history.js
I looked at the issues currently open with this library and it seems to be riddled with bugs, and I've not had time to source the exact problem I am having with it.
If and when I do, I'll try to get solr-ajax patched up and send you the pull request.
Thanks

Message: Object doesn't support this property or method with IE7 / IE8

Hello,

I changed the tutorial reuters to index/show results from a "db query". With IE7 and IE8 (firefox and chrome work fine) I get the error at line 30 of file reuters.theme.js

return $('').text(value).click(handler);

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)
Timestamp: Mon, 12 Mar 2012 16:45:32 UTC

Message: Object doesn't support this property or method
Line: 30
Char: 3
Code: 0
URI: http://XXXX/ajax-solr/data/lizeo/js/reuters.theme.js

Message: Object doesn't support this property or method
Line: 1
Char: 1
Code: 0
URI: http://XXXX:8983/solr/select?facet=true&facet.field=allText&facet.field=BRAND&facet.field=WEBSITE&facet.field=MARKET&facet.field=MATERIAL&facet.field=BI_SIZE&facet.field=SEASONALITY&facet.field=PREMIUM&facet.field=DISABLED&facet.field=ITEM_TYPE&facet.field=POSITIONING&facet.field=TREND&facet.field=PRICING_SIZE&q=_%3A_&facet.limit=100&facet.mincount=1&f.BRAND.facet.limit=50&f.MARKET.facet.limit=-1&json.nl=map&wt=json&json.wrf=jsonp1331570179826&_=1331570179873

Any suggestions?

Regards
Matteo

Add support for ElasticSearch

This has been mentioned in other threads, adding here as an official feature request. Elasticsearch is rapidly replacing Solr in a lot of organizations, and in general is a more modern, abstracted wrapper than Solr. I have used and love ajax-solr, would love to keep using it now that we've migrated to Elasticsearch, and I'm sure others feel the same.

Anyway - here for comment

Space characters in "facetLinks"

Hi!

I have downloaded AjaxSolr from github and tried it out with my "own" data. Everything seems to work fine but I'm experiencing some strange behaviour when rendering "facetLinks" in the result list. The problem seems to be that the code used to render facetLinks inserts a space-character between each character for a given facet. Say that we have a facet value of "WITS", it will be rendered as "W I T S". The facets are stored as Solr "string" types and when using the Solr Schema browser the values look 100% correct (no space characters).

I've had a look in the ResultWidget.js file but can't find anything that might introduce the effect mentioned above. What might be wrong here? Unfortunately I'm not able to give you access to our server as it is behind a firewall...

The code in the ResultWidget.js that renders a result:

facetLinks: function (facet_field, facet_values) {
    var links = [];
    if (facet_values) {
        for (var i = 0, l = facet_values.length; i < l; i++) {
            links.push(AjaxSolr.theme('facet_link', facet_values[i], this.facetHandler(facet_field, facet_values[i])));
        }
    }
return links;

}

The code in the ResultWidget.js that has been tweaked somewhat to render "my" facets:

afterRequest: function () {
    $(this.target).empty();
    for (var i = 0, l = this.manager.response.response.docs.length; i < l; i++) {
        var doc = this.manager.response.response.docs[i];
        $(this.target).append(AjaxSolr.theme('result', doc, AjaxSolr.theme('snippet', doc)));

       var items = [];
       items = items.concat(this.facetLinks('source', doc.source));
       items = items.concat(this.facetLinks('region', doc.region));
       items = items.concat(this.facetLinks('classification', doc.classification));
       AjaxSolr.theme('list_items', '#links_' + doc.id, items);
    }
}

The code in the reuters.theme.js that renders facet links:

AjaxSolr.theme.prototype.facet_link = function (value, handler) {
    return $('<a href="#"/>').text(value).click(handler);
};

Cheers

Add optional support for require.js

If people want to manage dependencies with require.js, we can add the necessary code to assist integration. Think about using it in the demo and tutorial.

Unable to fetch data from local solr application using ajax solr

I am trying to integrate ajax solr with my Spring MVC application and local solr application.But I am not able to fetch any data. I have asked the same question in stackoverflow http://stackoverflow.com/questions/25785520/unable-to-fetch-results-in-ajax-solr
I am able to run the demo shown here https://github.com/evolvingweb/ajax-solr/wiki/reuters-tutorial but when I change the solr url to my local solr application , it is not fetching any result.

Inheritance not working?

Unless I'm missing something about how the "class" abstraction is supposed to work, I would expect the test below against Core.js to log:

parent constructor
child constructor
parent method
child method

However, both the parent's constructor and the super handle are getting lost along the way. I don't fully understand all the shenanigans going on in Core.js, so it's possible that my usage or expectations are wrong. However, this is a practical issue in the library because when a class like ParameterHashStore extends ParameterStore, it isn't inheriting ParameterStore's default values for attributes like "exposed" and "params" which results in errors at runtime unless the instantiator of ParameterHashStore supplies those attributes itself.

var Parent = AjaxSolr.Class.extend({
    constructor: function() {
        console.log('parent constructor');
    },
    foo: function() {
        console.log('parent method');
    }
});
var Child = Parent.extend({
    constructor: function() {
        console.log('child constructor');
    },
    foo: function() {
        this.__super__.foo();
        console.log('child method');
    }
});
new Child().foo();

Fragment Identifier

In "Comparison to SolrJS" in the Browser Support section you mention using a fragment identifier for bookmarking a search filter and for back button undo of a selection, but the demo code does not seem to have this behavior. Can you point me to an example of how to use this fragment identifier? How would I use the fragment identifier with your demo? Many thanks. -Andrew

Add a widget for multiselect facets with configurable operand

Do you plan to add support for multi-select facets?
Here is a little example of what I would like to accomplish:

title:
[x] a (1111)

  • b (222)
  • c (333)
    [x] d (4)

author:
[x] a (123123)
[x] b (123)

  • c

After checking facets (marked as [x]) I would like the query to look like this:
(title:a OR title:d) AND (author:a OR author:b)

I would like not checked facets to not disappear and that all of them have appropriate counts.
I tried to use James McKinney tips from this question https://groups.google.com/forum/#!msg/ajax-solr/F8f6f3BtlUE/i3kdQYg_wzEJ but the constructed query looks like
/solr/select?rows=25&facet=true&facet.field={!ex=title}title&facet.field={!ex=author}author&fq={!tag=title}title:a&fq={!tag=title}title:d&fq={!tag=author}author:a&fq={!tag=author}author:b
so the operator is AND and I don't know how to change it to OR. I'm stuck.

It would be great if there was multi-select widget with configurable operand so users wouldn't have to change something withing Your code.

php proxy code needs update

the php proxy is a little stale, i had to make some changes for php 5.3/solr 3.5.0.
additionally, i added support for a core= parameter so that multiple cores can be handled with one proxy.
will attach revised code.

Replace the current theming stub with more modern tools

The theming framework within ajax-solr is 11 lines long, and there are a handful of theme helpers. Have the demo use Underscore or Mustache and removes the theming framework from ajax-solr. Nothing in core/ uses the theme layer anyhow.

Update demo and tutorial to use q parameter

The demo at the time was meant to be a drop-in replacement for the now dead SolrJs project, which made strange choices like using fq for the full-text query (instead of q) and doing autocomplete on facet fields. The code is already written, just need to update the docs and substitute the files in the demo.

Redeploy the demo; add security proxy

The demo exposes the /select API of an old version of Solr, which has a well known loophole - I was able to index a new document through /select, try search for "solr". Someone could just as easily delete the whole index. I think you know how to plug it :)

ERROR: Cannot read property 'length' of undefined

Hello
I have setup ajax-solr with my own index. Solr is running and is returning the results as expected. But when i try to communicate to it via this library, it returns this error:

Uncaught TypeError: Cannot read property 'length' of undefined
ResultWidget.js:60AjaxSolr.

Does anyone know how to resolve this?

Demo Site Not Working

This is an awesome resource but sadly I think there my be something wrong with demo site. It just shows the loading animation forever for me.
2016-01-20 08_17_22-ajax solr

plain old errors in theme functions reported as missing functions

the code below from Core.js consoles the message about 'undefined' if, in fact, the function is defined but throws something.

AjaxSolr.theme = function (func) {
  for (var i = 1, args = []; i < arguments.length; i++) {
    args.push(arguments[i]);
  }
  try {
    return (AjaxSolr.theme[func] || AjaxSolr.theme.prototype[func]).apply(this, args);
  }
 catch (e) {
    if (console && console.log) {
      console.log('Theme function "' + func + '" is not defined.');
    }
   throw e;
  }
};

Alternative storage engine for ParameterStore

fq values can be complex. What are our options?

  1. Store the complex values, and write a better parser
  2. Delegate responsibility for parameter storage to the widgets

In the second case, widgets can store simple values, which they know how to read to create a complex fq value. Developers should have to "opt-in" to taking this responsibility. Moving this logic out of ParameterStore into each widget means that developers need to think more carefully about which widget is responsible for which parameters/fields. It's not clear what the implementation would look like to preserve flexibility and expressivity.

Google Group discussion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.