<commit_before>load('mongo-fulltext/_load.js');
var s = db.ranking_works;
s.drop();
var full_vector_norm = false;


var fixture = [
    { "_id" : 1, "title" : "fish", "content" : "groupers like <NAME>" },
    { "_id" : 2, "title" : "dogs", "content" : "whippets kick mongrels" },
    { "_id" : 3, "title" : "dogs & fish", "content" : "whippets kick groupers" }
];
var conf = db.fulltext_config;
conf.insert({'collection_name' : 'ranking_works', 'fields': {'title': 5, 'content': 1}, 'params': {'full_vector_norm': full_vector_norm}});


mft.get('util').load_records_from_list(fixture, 'ranking_works');
var search = mft.get('search');
search.mapReduceIndex('ranking_works');

var result ;

// TODO: add index on collection name (should we have an _id attribute too?)
result = search.mapReduceSearch('ranking_works', 'fish');
result = db[res.result].find().sort({"value.score": 1}).toArray();

// print(result, "Search result for 'fish'");

assert.eq(result, [
        {
                "_id" : 1,
                "value" : 1.6666666666666667
        },
        {
                "_id" : 3,
                "value" : 1.386750490563073
        }
]);


result = search.mapReduceSearch('ranking_works', 'Dory').toArray();

// print(result, "Search result for 'Dory'");<commit_msg>fixing ranking_works to reflect new mapReduceSearch return signature<commit_after>load('mongo-fulltext/_load.js');
var s = db.ranking_works;
s.drop();
var full_vector_norm = false;


var fixture = [
    { "_id" : 1, "title" : "fish", "content" : "groupers like <NAME>" },
    { "_id" : 2, "title" : "dogs", "content" : "whippets kick mongrels" },
    { "_id" : 3, "title" : "dogs & fish", "content" : "whippets kick groupers" }
];
var conf = db.fulltext_config;
conf.insert({'collection_name' : 'ranking_works', 'fields': {'title': 5, 'content': 1}, 'params': {'full_vector_norm': full_vector_norm}});


mft.get('util').load_records_from_list(fixture, 'ranking_works');
var search = mft.get('search');
search.mapReduceIndex('ranking_works');

var result ;

// TODO: add index on collection name (should we have an _id attribute too?)
result = search.mapReduceSearch('ranking_works', 'fish');
result = db[result.result].find().sort({"value.score": 1}).toArray();

// print(result, "Search result for 'fish'");

assert.eq(result, [
        {
                "_id" : 1,
                "value" : 1.6666666666666667
        },
        {
                "_id" : 3,
                "value" : 1.386750490563073
        }
]);


result = search.mapReduceSearch('ranking_works', 'Dory');
result = db[result.result].find().sort({"value.score": 1}).toArray();

// print(result, "Search result for 'Dory'");
{'fraction_non_alphanumeric': 0.1853932584269663, 'fraction_numerical': 0.031086142322097377, 'mean_word_length': 3.5736301369863015, 'pattern_counts': {'":': 3, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4210284', 'n_tokens_mistral': 987, 'n_tokens_neox': 895, 'n_words': 203}