Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FacetsView Custom #28

Open
GwenCinoS opened this issue Apr 24, 2013 · 8 comments
Open

FacetsView Custom #28

GwenCinoS opened this issue Apr 24, 2013 · 8 comments

Comments

@GwenCinoS
Copy link

Your FacetsView is really great!

But I try to do it, in my own website, but I can't make any request, because my URL is like "http://extremesearch.cloudapp.net:9200/turbomanga/manga".
And I wanna know how to make request in a adresse like that, cause in FacetsView you have "http://bibsoup.net/query?"

So I wanna know how I can make request in my website! I was thinking about change default_url_params, but I failed!

Thx for your job, and to listen me! x) (Sorry if my english is bad...)

@markmacgillivray
Copy link
Contributor

Just set your search_url to http://extremesearch.cloudapp.net:9200/turbomanga/manga/_search?

Although I note from looking at that page there is a JSON error on it - would have to fix that on your own server side too, perhaps, it could be caused by something in your raw data that will be fine when queried against, just try it and see.

Also depending on if you are searching cross-domain or not, have a look at the option to set either JSON or JSONP.

@GwenCinoS
Copy link
Author

Oh ok thx! But I think I found an another way to do that! I need to know how can I change the request, I wanna do a POST, not a GET, how can I fix that?

@markmacgillivray
Copy link
Contributor

Ah OK, there is no option for that, but you can edit the dosearch() method directly in your local copy - line 1097.

I may add that as a configurable option.

@GwenCinoS
Copy link
Author

I see it, I change it, and this isn't working! ='/

$.ajax({
type: "post",
url: options.search_url,
data: {source: qrystr},
// processData: false,
dataType: options.datatype,
success: showresults
});

That's always send a GET! Damn it!

@markmacgillivray
Copy link
Contributor

Ah yes, of course, in order to send a POST you would also have to change the way the data is being delivered. Forgot about that.

data: {source: qrystr} is going to try to send a query parameter called source, which may be defaulting the ajax back to a GET. The data for a POST should probably be acceptable as just the JSON representation of the query rather than the string version. Try changing those settings around a bit until you get something that works - I have found when using elasticsearch endpoints with different providers they sometimes will only accept certain forms of ajax requests.

@GwenCinoS
Copy link
Author

Ok great! Thx for the help! x)

@GwenCinoS
Copy link
Author

One more thing! xD

I don't find any prob with my json, and I can do all request in it directly, so I don't think the prob was there, but, If I want to make a query like you with this : "http://extremesearch.cloudapp.net/query?" this isn't working... I just want to make a request on a title like this :

[{"_index":"turbomanga","_type":"manga","_id":"21","_score":0.2623265, "_source" : { "title": "gundam seed" ,"description": ""Terrestrial Defense Corp. Dai-Guard" is an anime television series, produced and animated by XEBEC, and directed by Seiji Mizushima. It aired from October 5, 1999 to March 28, 2000 on TV Tokyo, ran for 26 episodes. 6 volumes of videos were released on VHS and DVD. The series also had a very brief run (two episodes) on Cartoon Network through Toonami's "Giant Robot Week." "
,"Tags":["Action", "Combat"] }
}]},"facets":{"tags":{"_type":"terms","missing":0,"total":2,"other":0,"terms":[{"term":"combat","count":1},{"term":"action","count":1}]}}}

This is so simple, I try it with Elastic.js, the query works but I can't make it with facetsview that will make me craaaaaazy! @.@

@markmacgillivray
Copy link
Contributor

Do you have some backend code to support queries arriving at extremsearch.cloudapp.net/query?

The example in facetview is sending that query to an instance of bibserver - http://github.com/okfn/bibserver - which does have code to handle requests to /query. It validates them then passes them through to our index with some tweaking as required for our own apps.

If you have written some backend code but are not getting back what you expect, check that you are properly handling JSONP, or you will not succeed in requesting the data from cross-domain sources. Have a look at the bibserver code mentioned above if you want to see how to do this in python.

However if you do not have code to handle the /query endpoint, it should work just as well sending direct to your elasticsearch _search endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants