appbaseio / mirage

:art: GUI for simplifying Elasticsearch Query DSL
http://opensource.appbase.io/mirage
Other
2.21k stars 123 forks source link

Trying to get working against a version 5.x ES #5

Closed Analect closed 8 years ago

Analect commented 8 years ago

Thanks for a great project. I was wondering if you might be able to point me in the right direction. I have the default match_all query running fine against a local version 5.x-alpha4 elasticsearch installation.

However, when it comes to assembling a nested query, it isn't allowing me to build up the query. I'm assuming it might have something to do with the new mapping types introduced in 5.x, where for instance type: text and type: keyword replace type: string.

A portion of my mapping looks like this:

{
    "content_private0": {
        "mappings": {
            "note": {
                "properties": {
                    "access": {
                        "type": "keyword"
                    },
                    "archived_at": {
                        "type": "date"
                    },
                    "backdated": {
                        "type": "boolean"
                    },
                    "body": {
                        "type": "text",
                        "analyzer": "customHTMLSnowball"
                    },
                    "create_at": {
                        "type": "date"
                    },
                    "curated": {
                        "type": "boolean",
                        "fields": {
                            "keyword": {
                                "type": "keyword"
                            }
                        }
                    }
                }
            }
        }
    }
}

As per screenshot below, when I try to add a condition pertaining to the body field, it doesn't give me any options. Is this because it doesn't know what type: text is?

image

Even for the create_at date field (not a new type), it also doesn't appear to be able to interpret the date field .. does it need to be a unix-type date to work?

image

Any pointers you might have to get this working against my mapping on ES 5.x would be much appreciated.

farhan687 commented 8 years ago

@Analect Thanks for reporting issue, We didn't test it yet with Es version 5.x. But it looks like you already gave the solution for string type.

You are right about date type, mirage is not working well for date type. We will try to resolve this issue as soon as possible.

Analect commented 8 years ago

Thanks @farhan687 Is there a particular place in the code that is testing for string type, where I might try to tweak to handle the text and/or keyword types?

farhan687 commented 8 years ago

@Analect You can try over here: https://github.com/appbaseio/mirage/blob/dev/app/build/types/types.component.ts#L68

Analect commented 8 years ago

@farhan687 I was taking a closer look at this to see if I might be able to modify things to get it working with ES 5.x I can see in the link above, that where field mappings are not of 'string' type, then they are bundled into a 'numeric' type. The black box on the left below, with either 'string' or 'numeric' against mirgage_test work fine.

However, when I adjust the index and credentials in the code to point to my own ES 5.x index, and try to generate a new query against type 'note', then this mapping breaks down. There's obviously somewhere else in the code that enables conditions to be added based on either field types 'string' or 'numeric', which is failing, given my ES 5.x is using the replacements to 'string' ... 'text' and 'keyword'. The mapping of the mapping (if I can call it that) is also not handling fields that have various mapping types (such as entities in the blue box below).

In fact, the only field that will work for me (ie. allow me to create a query) is priority (green box below), whose 'byte' type gets converted into 'numeric', by the existing code.

image

I would love to be able to get this working against 5.x. Would you be able to suggest how I might tweak things to better handle the 'text/keyword' , 'boolean' and 'date' type fields. Thanks. Colum

farhan687 commented 8 years ago

@Analect Try something like this

` switch (obj.type) {

case 'long':
case 'integer':
case 'short':
case 'byte':
case 'double':
case 'float':
    obj.type = 'numeric';
    break;
case 'text':
case 'keyword':
    obj.type = 'string';
    break;

}; `

over here: https://github.com/appbaseio/mirage/blob/dev/app/build/types/types.component.ts#L68

By doing this mirage will consider 'text' or 'keyword' as string.

For boolean and date types, give me sometime, I will surely look into that.

Analect commented 8 years ago

@farhan687 Great. That worked. Thanks. Would you be able to shed any light on why mirage doesn't appear to work with an index alias? This is the exception that throws (screenshot below), when I try to use an alias of an index (it is a filtered alias) .. it appears to connect OK ... but doesn't resolve the document types (on left window) ... or append /_search/ to finalURL on the right window.

image

One other thing I noticed, in a simple match_phrase query ... it fails to save the input value ... even in the local storage JSON. I'm not sure if this is linked to the other matter resolved above or not.

So, here's a basic query ... image ... which I save ... but then when I try to retrieve the query ... the Input field is blank. image

I notice that this same field is also missing from the query, as stored in localstorage too.

"selectedTypes": ["note"],
    "result": {
        "resultQuery": {
            "type": "",
            "result": [{
                "boolparam": 0,
                "parent_id": 0,
                "id": 1,
                "internal": [{
                    "field": {
                        "name": "title",
                        "type": "string",
                        "index": null
                    },
                    "query": "1",
                    "selectedField": "title",
                    "selectedQuery": "match_phrase",
                    "input": "",
                    "analyzeTest": "analyzed",
                    "type": "string",
                    "appliedQuery": {
                        "match_phrase": {
                            "title": ""
                        }
                    }
                }],
                "minimum_should_match": "",
                "availableQuery": [{
                    "match_phrase": {
                        "title": ""
                    }
                }]
            }]
siddharthlatest commented 8 years ago

We should look at the 5.0 compatibility more so now that it's GA.

farhan687 commented 8 years ago

Fixed over here 944686350e57bccbcc208e8259fb8c112dc71bca

siddharthlatest commented 8 years ago

Released in v0.4.0.