martin-magakian / Amazing-Cloud-Search

Allow you to search, faceted search, add, update, remove objects from your Amazon Cloud Search Index in C#.
30 stars 17 forks source link

A new grouped condition #5

Closed valencianok closed 10 years ago

valencianok commented 10 years ago

A new grouped condition and the option to negate a string condition

martin-magakian commented 10 years ago

It look like a cool feature. I will try it soon.

Can you write a quick note in the documentation about it? Also can write some unit test? The idea it to prevent someone else from breaking your code

radavies commented 10 years ago

I was just about to ask if this was part of the current build, looking forward to seeing this added as I also need it for my project :)

martin-magakian commented 10 years ago

It look ok to me. But I still wan't to test it to make sure. I will have time to add it friday this week or monday next week.

I just wish valencianok could had some unit test and some doc as you did :-)

martin-magakian commented 10 years ago

I wrote some unit test for you as well as updated the documentation.

It's now in the master branch.

valencianok commented 10 years ago

Hi Martin

Its great news to see you merged. Sorry I did not answered before but was out of reach for a few days. Let me know if there is something else to do for this.

Regards

Kenneth Valenciano

On 10/20/2013 10:23 AM, Martin Magakian wrote:

I wrote some unit test for you as well as updated the documentation.

It's now in the master branch.

— Reply to this email directly or view it on GitHub https://github.com/martin-magakian/Amazing-Cloud-Search/pull/5#issuecomment-26676307.

martin-magakian commented 10 years ago

No problem Kenneth. The feature you added is pretty cool by the way.

Can you validate my thinking on some points?

1) How the HTTP request should look like for: (movies in 1990 + genre "Sci-Fi") OR (movies in 2013 + genre "Fantasy")

var condition1A = new StringBooleanCondition("genre", "Sci-Fi");
var condition1B = new IntBooleanCondition("year");
condition1B.SetFrom(1990);
var groupCondition1 = new GroupedCondition(condition1A, ConditionType.AND, condition1B);

var condition2A = new StringBooleanCondition("genre", "Fantasy");
var condition2B = new IntBooleanCondition("year");
condition2B.SetFrom(2013);
var groupCondition2 = new GroupedCondition(condition2A, ConditionType.AND, condition2B);

var groupConditionAll = new GroupedCondition(groupCondition1, ConditionType.OR, groupCondition2);

it produce the query: (and+(or+(and+genre%3A'Sci-Fi'+year%3A1990..)+(and+genre%3A'Fantasy'+year%3A2013..)))

It look correct to me. Do you confirm the query is build correctly?

2) How the HTTP request should look like for: (genre ("Sci-Fi" or Fantasy) AND (year 1987 or 1990 or 2010)) AND (director "doduck")

        var genres = new List<string> { "Sci-Fi", "Fantasy" };
        var condition1A = new StringListBooleanCondition("genre", genres, ConditionType.OR);
        var years = new List<int> { 1987, 1990, 2010 };
        var condition1B = new IntListBooleanCondition("year", years, ConditionType.OR);
        var groupCondition1 = new GroupedCondition(condition1A, ConditionType.AND, condition1B);

        var condition2 = new StringBooleanCondition("director", "doduck");

        var groupConditionAll = new GroupedCondition(groupCondition1, ConditionType.AND, condition2);

        var bQuery = new BooleanQuery();
        bQuery.Conditions.Add(groupConditionAll);

It produce the query: (and+(or+(and+genre%3A'Sci-Fi'+genre%3A'Fantasy'+year%3A1987+year%3A1990+year%3A2010)+director%3A'doduck'))

It doesn't look correct to me. It should look like: (and+(and+(or+genre%3A'Sci-Fi'+genre%3A'Fantasy')+(or+year%3A1987+year%3A1990+year%3A2010)+director%3A'doduck'))

Thanks

martin-magakian commented 10 years ago

I open an issue #7 + create an unit test who expose the problem