Monday, August 16, 2010

Sphinx extended query syntax

One advice I should give is about the syntax of query.

I your text-search involves more than one attribute, then you have two choices to build your query like:
1. Query: @attr1 "*keyword*" | @attr2 "*keyword*" | @attr3 "*keyword*"
2. Query: @(attr1|attr2|attr3) "*keyword*"

Now benchmarking:
1st Query, on 1000 iterations, took 23.2s of pure sphinx time
2nd Query, on 1000 iterations, took 16.2s of pure sphinx time.

Make you conclusions... ;)

PS: I also tried 3rd approach:
I made concatenated attribute, named it @attr1_attr2_attr3 in sphinx's configuration file, and query's format was like:
@attr1_attr2_attr3 "*keyword*"... 1000 iterations of this type of query, took 17.9 seconds... much better than 1st one, but still 2nd is better.

Wednesday, August 11, 2010

Bromine first install. Fatal error

I love those tricky moments, when you have to dance with a tambourine around your pc, to make it work using our galaxy logic etc.

So, the problem: I got following error when first started, freshly unzipped bromine project:


Notice: Trying to get property of non-object in /usr/home/.../www/cake/libs/cache/file.php on line 244

Fatal error: Call to a member function cd() on a non-object in /usr/home/.../www/cake/libs/cache/file.php on line 244

It's under FreeBSD (that should be important moment I guess).

You wanna know how this SHOULD be fixed?
Here is what I've found:

Go to www/app/config/core.php's line stating:
date_default_timezone_set('UTC');
and uncomment it.

Cake engine does not like when this line is commented out and acts unpredictably

IE8 dynamically created tables

I had to generate tables and append them to DOM dynamically (on ajax data requests responded).

IE8 acted as a bad-ass teacher to me, cuz I forgot to use tbody tag. So hopefully that helps:

BAD code:
var table = document.createElement("table");
var tr = document.createElement("tr");
table.appendChild(tr);
...
document.appendChild(table);

GOOD code:
var table = document.createElement("table");
var tbody = document.createElement("tbody");
var tr = document.createElement("tr");
tbody.appendChild(tr);
table.appendChild(tbody);
...
document.appendChild(table);

Otherwise IE ignores the content of your table and shows it with zero height and zero width.

I should mention, that IE8's Developer Tools did help me to find that out ;)

Niivisi

HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)

When creating dynamically generated pages, you can meet following error in IE browser:

HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)

That "KB927917" secret code also comes along with

Line: 0
Character: 0
Source: 0

So now you "know" where to dig to.

So I met one. And it was odd, cuz my JS is runing on Jquery's document.ready event, when everything should be ready:

$(document).ready(function(){
... my js ...
});

But it does not make any sense for IE? No. For FF3, Chrome, etc. does, but not for IE. So what does?

$(document).ready(function(){
setInterval("documentIsReallyReadyNowEvenInIE();",1000);
});
function documentIsReallyReadyNowEvenInIE() {
... my js ...
}

Вот-так-то