DrupalCon Prague 2013

Realiza búsquedas espectaculares con la API Search

Thomas Seidl  · 
API

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

is a truth universally acknowledged at in life demo anything that can go wrong will go wrong hello and welcome to this session my name is Thomas idle and in the next 45 minutes I'll show you how to create amazing searches with the Search API on your site

the session will be a live demo and while that of course spells disaster for nearly everyone in this room and the wearing of protective gear is strongly recommended it does have two distinct upside that if I actually manage to set up a virtual search under

these circumstances and it's almost guaranteed that nothing at all can possibly go wrong when you do the same at all sounds good then let's start but before I actually start with the demo I'll give you a quick overview about the Search API and

the Search API is a module developed by me since 2010 at that time there was some discussion about core search in triple-eight how it could be improved from the strictly product that it was in Troopa 7 how it could be a flexible framework for creating diverse

searches based on it with country modules actually a little of this was eventually implemented in triple-eight but I took most of these ideas and functionality and incorporated them into this search API module so with the search append module you're not

restricted to searching nodes with the database you can use a different various set of backends you can use any almost any kind of data on your site and you have great control over how this data will be indexed and displayed to the users so how does this work

at the basic structure as far as cycles are concerned there are two sets of entities that you can that you have to use for creating searches with Search API at first our search indexes these a generic information about the kind of data that you want to index

what what about them to want to index and what we want to pre-process them and for example so you want to index a set of all nodes from the site which fields you want to index and so on and search servers implement the technical details they represent how

this search actually works how this implement is what is used to index the dates and later retrieve it during searches so this can use the database can use a picture solar which is a open source search engine in case you didn't know and some other backends

they're also available other search engines like stinks or sapien and yeah this is technical implementation and an index then uses a single server to - it's real operations and all other modules just build on a generic information in the index and

that does independent of the server so the server can also lay to be switched out if you want to and severus indexes use the same server so on a typical site you will only have a single search server that uses a database or solar or whatever you have available

and all indexes for whatever type of information you want to index then use this server so now that this is all has been dealt with just a few safety precautions and with that let's get dangerous so the journey starts as always by just enabling our modules

the entity a via the entity API module is I want you I couldn't have planned this better really the first thing I do okay yeah it always of course takes some time to enable the modules the entity API module which I enabled is a dependency of the Search

API so you always have to anneal debt and database search and so a search are the two modules that offer the search backends their respective ones so if you want to search using the database you have to in any ability to be search module and for solar the

other one these are separate modules that you'll have to download separately from the Search API so now that we have these modules installed we first add a server as the name we can choose and choose anything you want and the service class is what is then

used for actually searching so um database is very easy to set up you just have a single option so I won't show you that instead I'll quickly show you how you can set up a solar server on your own site so this is the contact information for the server

you'd have to change that for using other types of servers but for the one I'm about to show you to set out how to set up the default settings are already the right ones so here I have downloaded the latest version of Apache Solr I just extracted archived

now and then I have to go into the Search API solar module use the right configuration so this is solar for so we have to use the 4th of X configuration files and then we just copy them over into Soler's this is the example application it is provided with

solar and here we have to find the configuration directory and copy this data over I don't copy this one because the default settings are already very good for that one now we only have to go into that directory and execute this command on a command line

of course Java needs to be installed with that and with only that we have a working solar server for our Drupal site and of course if you have solar available if you have two possibility to use it it's always a good idea because it has better performance

and returns paid results there's more functionality than using a database server and now if you refresh the page we see that the server could be reached and decide the search server at least is now working just a quick note about that the way I've

set it up right now is we're insecure on a production site or anywhere reachable from the internet because this wouldn't be at all protect against all set access if someone would just append the right port to the to your domain they could then manipulate

the solar date in any way you want delete date or add advertisements or anything so you really have to protect against that to do that you can either add some hash to the path so for the um let's see for the solar directory here you can just rename that

to anything else solar with 30 random characters appended to it and then people would have of course a hard time guessing what it was so that would be a protection you could just block off the excess with a fireball which is of course only possible if the

solar server is only accessed locally so if the web server is running on the same machine and you can also use HTTP authentication you can look that up how that this down yeah we are a Google of course so we now have a working in the server so now we also

need an index I just bookmarked out we could also use the default note index which already has a well working configuration for nodes but I rather show you how to create your own one for that we here have to a select the item type and in this example we just

use nodes and here we select the server we just created and we any will this option but that also am do a quick side note this option when enabled leads to notes that are being saved either inserted or newly created or edited to be indexed immediately on the

search server so otherwise you might have stale data on the on the server on the search server which would then lead to false search results or if you use the index data to to some excess checks so to filter for only published nodes and this would even lead

to a security concerns if you don't index items immediately although users might wonder that when they create a node why doesn't it show in lists right away so if all sadducees 10 create nodes on your site this is also equal to t adjust because to

use experience and often a contra site there's of course that what when a node is saved they would have the user would then have to wait for a node P to be indexed to be forward to the next site and to the next page so this is especially if you have some

more complex operations during indexing yeah a consideration also for user experience and also there are performance issues if you push one document at a time especially to Soler instead of pushing a whole bunch if you um index a whole bunch at the time then

it's more performant for solar at least but all that doesn't really matter for the contrast don't really matter for smaller sites so for death will just use um we just enable the option then click on create index now that we have these basic settings

after way we can choose which fields we want to index on the server for this index here we have all the nodes fields available and also this option to add the fields related somehow to their node so we can for example use the author click add fields here and

[ ... ]

Nota: se han omitido las otras 4.261 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.