├── resize ├── .DS_Store ├── input │ └── 2.jpg ├── .resize.sh.swp └── resize.sh ├── app ├── src │ ├── index.css │ ├── index.js │ ├── App.test.js │ ├── App.css │ ├── App.js │ ├── logo.svg │ ├── components │ │ ├── Detail.js │ │ └── Main.js │ └── registerServiceWorker.js ├── public │ ├── favicon.ico │ ├── manifest.json │ └── index.html ├── .gitignore ├── package.json └── README.md ├── .idea ├── misc.xml ├── vcs.xml ├── modules.xml ├── Elastic-manga.iml └── workspace.xml ├── es-py ├── es-main.py └── mapping.json ├── docker └── Dockerfile └── .gitignore /resize/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaaaaaaaaaaai/elastic-manga/master/resize/.DS_Store -------------------------------------------------------------------------------- /app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /resize/input/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaaaaaaaaaaai/elastic-manga/master/resize/input/2.jpg -------------------------------------------------------------------------------- /resize/.resize.sh.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaaaaaaaaaaai/elastic-manga/master/resize/.resize.sh.swp -------------------------------------------------------------------------------- /app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaaaaaaaaaaai/elastic-manga/master/app/public/favicon.ico -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import registerServiceWorker from './registerServiceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | registerServiceWorker(); 9 | -------------------------------------------------------------------------------- /app/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/Elastic-manga.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /app/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 80px; 8 | } 9 | 10 | .App-header { 11 | background-color: #222; 12 | height: 150px; 13 | padding: 20px; 14 | color: white; 15 | } 16 | 17 | .App-title { 18 | font-size: 1.5em; 19 | } 20 | 21 | .App-intro { 22 | font-size: large; 23 | } 24 | 25 | @keyframes App-logo-spin { 26 | from { transform: rotate(0deg); } 27 | to { transform: rotate(360deg); } 28 | } 29 | -------------------------------------------------------------------------------- /app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "axios": "^0.17.1", 7 | "material-ui": "^1.0.0-beta.32", 8 | "material-ui-icons": "^1.0.0-beta.17", 9 | "react": "^16.2.0", 10 | "react-dom": "^16.2.0", 11 | "react-helmet": "^5.2.0", 12 | "react-router-dom": "^4.2.2", 13 | "react-scripts": "1.1.0" 14 | }, 15 | "scripts": { 16 | "start": "react-scripts start", 17 | "build": "react-scripts build", 18 | "test": "react-scripts test --env=jsdom", 19 | "eject": "react-scripts eject" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /resize/resize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | pwd=$(pwd) 3 | for file in `ls ./input/`; do 4 | HEIGHT=$(sips -g pixelHeight -g pixelWidth ./input/${file} | grep pixelHeight | awk '{print $2}') 5 | WIDTH=$(sips -g pixelHeight -g pixelWidth ./input/${file} | grep pixelWidth | awk '{print $2}') 6 | echo $HEIGHT; 7 | echo $WIDTH; 8 | DH=`expr 2 \* $HEIGHT` 9 | echo $DH 10 | if [ $DH -lt $WIDTH ] ; then 11 | ffmpeg -y -i ./input/${file} -vf "pad='if(gt((iw/2)-ih, 0),300,(ih*2))':0:(ow-iw)/2:0:white" ./output3/${file} 12 | continue 13 | fi 14 | 15 | ffmpeg -y -i ./input/${file} -vf "pad=(ih*2):0:(ow-iw)/2:0:white" ./output2/${file} 16 | done -------------------------------------------------------------------------------- /es-py/es-main.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from pprint import pprint 3 | from elasticsearch import Elasticsearch 4 | 5 | 6 | def main(): 7 | json = pd.read_json("./document.json") 8 | pprint(json["data"]) 9 | 10 | es = Elasticsearch("https://search-manga-image-sdozidc55hog2xc6ryonyshlja.ap-northeast-1.es.amazonaws.com") 11 | 12 | for data in json["data"].iteritems(): 13 | d = { 14 | "extension":data[1]["extension"], 15 | "tags": data[1]["tags"], 16 | "plane_tags": data[1]["tags"] 17 | } 18 | pprint(es.index(index="prod", doc_type="image", id= data[1]["id"], body=d)) 19 | 20 | 21 | 22 | if __name__ == '__main__': 23 | main() 24 | -------------------------------------------------------------------------------- /es-py/mapping.json: -------------------------------------------------------------------------------- 1 | { 2 | "settings": { 3 | "index": { 4 | "analysis": { 5 | "analyzer": { 6 | "my_ja_analyzer": { 7 | "type": "custom", 8 | "tokenizer": "kuromoji_tokenizer", 9 | "char_filter": [ 10 | "icu_normalizer", 11 | "kuromoji_iteration_mark" 12 | ], 13 | "filter": [ 14 | "kuromoji_baseform", 15 | "kuromoji_part_of_speech", 16 | "ja_stop", 17 | "kuromoji_number", 18 | "kuromoji_stemmer" 19 | ] 20 | } 21 | } 22 | } 23 | } 24 | }, 25 | "mappings": { 26 | "extended_publish_articles": { 27 | "dynamic": "strict", 28 | "properties":{ 29 | "id": { 30 | "type": "integer" 31 | }, 32 | "extension": { 33 | "type": "text", 34 | "index": "not_analyzed" 35 | }, 36 | "tags": { 37 | "type": "text", 38 | "analyzer": "my_ja_analyzer", 39 | "fielddata": true 40 | 41 | }, 42 | "plane_tags": { 43 | "type": "text", 44 | "index": "not_analyzed", 45 | "fielddata": true 46 | } 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 22 | 漫画1コマ検索 23 | 24 | 25 | 28 |
29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos6 2 | 3 | MAINTAINER Kai ogita 4 | 5 | # install epel and packages 6 | RUN rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm && \ 7 | rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && \ 8 | yum -y update --enablerepo=epel,remi,remi-php56 && yum clean all 9 | RUN yum -y install --enablerepo=epel,remi,remi-php56 \ 10 | git openssh-server openssh-clients passwd vim \ 11 | php php-devel php-common php-cli php-pear php-xml \ 12 | php-mbstring php-gd php-mcrypt php-pdo php-mysql php-pecl-imagick php-pecl-memcached php-pecl-apc php-pecl-memcache \ 13 | memcached ImageMagick cronie sendmail 14 | 15 | RUN ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key && \ 16 | ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key && \ 17 | sed -ri 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config && echo 'root:changeme' | chpasswd 18 | 19 | # Create known_hosts 20 | RUN mkdir /root/.ssh/ && \ 21 | touch /root/.ssh/known_hosts && \ 22 | echo -e "Host bitbucket.org\n\ 23 | HostName bitbucket.org\n\ 24 | User git\n\ 25 | IdentityFile ~/.ssh/id_rsa\n\ 26 | IdentitiesOnly yes\n\ 27 | StrictHostKeyChecking no" >> /root/.ssh/config && \ 28 | echo -e "Host github.com\n\ 29 | HostName github.com\n\ 30 | User git\n\ 31 | IdentityFile ~/.ssh/id_rsa\n\ 32 | IdentitiesOnly yes\n\ 33 | StrictHostKeyChecking no" >> /root/.ssh/config 34 | 35 | # Default Time Zone 36 | RUN ln -sf /usr/share/zoneinfo/Japan /etc/localtime 37 | 38 | # setting japanese http://qiita.com/snaka/items/55fc351ef61c12bc09a5 39 | RUN echo 'LANG="ja_JP.UTF-8"' > /etc/sysconfig/i18n && localedef -f UTF-8 -i ja_JP ja_JP 40 | 41 | # ADD files 42 | RUN yum -y install wget java 43 | RUN wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.4.tar.gz 44 | RUN sha1sum elasticsearch-5.6.4.tar.gz 45 | RUN tar -xzf elasticsearch-5.6.4.tar.gz 46 | RUN cd elasticsearch-5.6.4/ 47 | RUN ls 48 | RUN /elasticsearch-5.6.4/bin/elasticsearch-plugin install analysis-kuromoji 49 | RUN /elasticsearch-5.6.4/bin/elasticsearch-plugin install analysis-icu -------------------------------------------------------------------------------- /app/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import logo from './logo.svg'; 3 | import './App.css'; 4 | import { createMuiTheme } from 'material-ui/styles'; 5 | import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider' 6 | import createPalette from 'material-ui/styles/createPalette'; 7 | import blue from 'material-ui/colors/blue'; 8 | import pink from 'material-ui/colors/pink'; 9 | import red from 'material-ui/colors/red'; 10 | import PropTypes from 'prop-types'; 11 | import { withStyles } from 'material-ui/styles'; 12 | import AppBar from 'material-ui/AppBar'; 13 | import Toolbar from 'material-ui/Toolbar'; 14 | import Typography from 'material-ui/Typography'; 15 | import Main from "./components/Main"; 16 | import { BrowserRouter as Router, Route, Link , Switch} from 'react-router-dom' 17 | 18 | import Detail from "./components/Detail" 19 | 20 | 21 | const theme = createMuiTheme({ 22 | palette: createPalette({ 23 | primary: blue, 24 | accent: pink, 25 | error: red, 26 | }), 27 | }); 28 | 29 | const styles = { 30 | root: { 31 | width: '100%', 32 | }, 33 | }; 34 | 35 | class App extends Component { 36 | render() { 37 | const { classes, history } = this.props; 38 | return ( 39 | 40 | 41 |
42 |
43 | 44 | 45 | 46 | 漫画1コマ検索 47 | 48 | 49 | 50 |
51 |
52 | 53 | 54 | 55 | 56 |
57 |
58 |
59 |
60 | ); 61 | } 62 | } 63 | 64 | export default withStyles(styles)(App); 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | resize/input 2 | resize/output 3 | 4 | # Created by .ignore support plugin (hsz.mobi) 5 | ### JetBrains template 6 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 7 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 8 | 9 | # User-specific stuff: 10 | .idea/**/workspace.xml 11 | .idea/**/tasks.xml 12 | .idea/dictionaries 13 | 14 | # Sensitive or high-churn files: 15 | .idea/**/dataSources/ 16 | .idea/**/dataSources.ids 17 | .idea/**/dataSources.xml 18 | .idea/**/dataSources.local.xml 19 | .idea/**/sqlDataSources.xml 20 | .idea/**/dynamic.xml 21 | .idea/**/uiDesigner.xml 22 | 23 | # Gradle: 24 | .idea/**/gradle.xml 25 | .idea/**/libraries 26 | 27 | # CMake 28 | cmake-build-debug/ 29 | 30 | # Mongo Explorer plugin: 31 | .idea/**/mongoSettings.xml 32 | 33 | ## File-based project format: 34 | *.iws 35 | 36 | ## Plugin-specific files: 37 | 38 | # IntelliJ 39 | out/ 40 | 41 | # mpeltonen/sbt-idea plugin 42 | .idea_modules/ 43 | 44 | # JIRA plugin 45 | atlassian-ide-plugin.xml 46 | 47 | # Cursive Clojure plugin 48 | .idea/replstate.xml 49 | 50 | # Crashlytics plugin (for Android Studio and IntelliJ) 51 | com_crashlytics_export_strings.xml 52 | crashlytics.properties 53 | crashlytics-build.properties 54 | fabric.properties 55 | ### Node template 56 | # Logs 57 | logs 58 | *.log 59 | npm-debug.log* 60 | yarn-debug.log* 61 | yarn-error.log* 62 | 63 | # Runtime data 64 | pids 65 | *.pid 66 | *.seed 67 | *.pid.lock 68 | 69 | # Directory for instrumented libs generated by jscoverage/JSCover 70 | lib-cov 71 | 72 | # Coverage directory used by tools like istanbul 73 | coverage 74 | 75 | # nyc test coverage 76 | .nyc_output 77 | 78 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 79 | .grunt 80 | 81 | # Bower dependency directory (https://bower.io/) 82 | bower_components 83 | 84 | # node-waf configuration 85 | .lock-wscript 86 | 87 | # Compiled binary addons (https://nodejs.org/api/addons.html) 88 | build/Release 89 | 90 | # Dependency directories 91 | node_modules/ 92 | jspm_packages/ 93 | 94 | # Typescript v1 declaration files 95 | typings/ 96 | 97 | # Optional npm cache directory 98 | .npm 99 | 100 | # Optional eslint cache 101 | .eslintcache 102 | 103 | # Optional REPL history 104 | .node_repl_history 105 | 106 | # Output of 'npm pack' 107 | *.tgz 108 | 109 | # Yarn Integrity file 110 | .yarn-integrity 111 | 112 | # dotenv environment variables file 113 | .env 114 | 115 | 116 | -------------------------------------------------------------------------------- /app/src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/components/Detail.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import Grid from 'material-ui/Grid'; 3 | import Helmet from "react-helmet"; 4 | import Card, { CardActions, CardContent, CardMedia } from 'material-ui/Card'; 5 | import Button from 'material-ui/Button'; 6 | import { withStyles } from 'material-ui/styles'; 7 | import Avatar from 'material-ui/Avatar'; 8 | import Typography from 'material-ui/Typography'; 9 | import Paper from 'material-ui/Paper'; 10 | import Attachment from "material-ui-icons/Attachment" 11 | import axios from "axios/index"; 12 | 13 | const styles = theme => ({ 14 | card: { 15 | maxWidth: 345, 16 | }, 17 | media: { 18 | height: 200, 19 | }, 20 | demo: { 21 | height: 240, 22 | margin: 50 23 | }, 24 | url_text:{ 25 | textAlign: "center" 26 | } 27 | }); 28 | 29 | const s3 = "https://s3-ap-northeast-1.amazonaws.com/manga-one"; 30 | 31 | 32 | class Detail extends React.Component{ 33 | constructor(props){ 34 | super(props) 35 | this.getDataById = this.getDataById.bind(this) 36 | 37 | this.state = {image_url:"http://www.filife.com/wp-content/themes/qaengine/img/default-thumbnail.jpg"} 38 | console.log(this.state.image_url); 39 | 40 | if(typeof(this.props.location.state) == "undefined"){ 41 | console.log("aaaaaaa") 42 | this.getDataById(this.props.match.params.id) 43 | }else{ 44 | console.log("bbbbb") 45 | 46 | this.state = this.props.location.state 47 | } 48 | } 49 | 50 | componentWillMount() { 51 | this.setState({image_url:"http://www.filife.com/wp-content/themes/qaengine/img/default-thumbnail.jpg"}) 52 | 53 | } 54 | 55 | getDataById(id){ 56 | console.log() 57 | axios.get(`http://localhost:9200/prod/image/${id}`).then((res) => { 58 | console.log(res) 59 | this.setState(res.data._source) 60 | }); 61 | } 62 | render(){ 63 | const {classes} = this.props 64 | return ( 65 | 66 | 79 | 80 | 86 | 87 | 88 | 89 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | {window.location.href} 105 | 106 | 107 | 108 | 109 | 110 | 111 | ) 112 | } 113 | } 114 | 115 | export default withStyles(styles)(Detail) -------------------------------------------------------------------------------- /app/src/registerServiceWorker.js: -------------------------------------------------------------------------------- 1 | // In production, we register a service worker to serve assets from local cache. 2 | 3 | // This lets the app load faster on subsequent visits in production, and gives 4 | // it offline capabilities. However, it also means that developers (and users) 5 | // will only see deployed updates on the "N+1" visit to a page, since previously 6 | // cached resources are updated in the background. 7 | 8 | // To learn more about the benefits of this model, read https://goo.gl/KwvDNy. 9 | // This link also includes instructions on opting out of this behavior. 10 | 11 | const isLocalhost = Boolean( 12 | window.location.hostname === 'localhost' || 13 | // [::1] is the IPv6 localhost address. 14 | window.location.hostname === '[::1]' || 15 | // 127.0.0.1/8 is considered localhost for IPv4. 16 | window.location.hostname.match( 17 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 18 | ) 19 | ); 20 | 21 | export default function register() { 22 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 23 | // The URL constructor is available in all browsers that support SW. 24 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location); 25 | if (publicUrl.origin !== window.location.origin) { 26 | // Our service worker won't work if PUBLIC_URL is on a different origin 27 | // from what our page is served on. This might happen if a CDN is used to 28 | // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 29 | return; 30 | } 31 | 32 | window.addEventListener('load', () => { 33 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 34 | 35 | if (isLocalhost) { 36 | // This is running on localhost. Lets check if a service worker still exists or not. 37 | checkValidServiceWorker(swUrl); 38 | 39 | // Add some additional logging to localhost, pointing developers to the 40 | // service worker/PWA documentation. 41 | navigator.serviceWorker.ready.then(() => { 42 | console.log( 43 | 'This web app is being served cache-first by a service ' + 44 | 'worker. To learn more, visit https://goo.gl/SC7cgQ' 45 | ); 46 | }); 47 | } else { 48 | // Is not local host. Just register service worker 49 | registerValidSW(swUrl); 50 | } 51 | }); 52 | } 53 | } 54 | 55 | function registerValidSW(swUrl) { 56 | navigator.serviceWorker 57 | .register(swUrl) 58 | .then(registration => { 59 | registration.onupdatefound = () => { 60 | const installingWorker = registration.installing; 61 | installingWorker.onstatechange = () => { 62 | if (installingWorker.state === 'installed') { 63 | if (navigator.serviceWorker.controller) { 64 | // At this point, the old content will have been purged and 65 | // the fresh content will have been added to the cache. 66 | // It's the perfect time to display a "New content is 67 | // available; please refresh." message in your web app. 68 | console.log('New content is available; please refresh.'); 69 | } else { 70 | // At this point, everything has been precached. 71 | // It's the perfect time to display a 72 | // "Content is cached for offline use." message. 73 | console.log('Content is cached for offline use.'); 74 | } 75 | } 76 | }; 77 | }; 78 | }) 79 | .catch(error => { 80 | console.error('Error during service worker registration:', error); 81 | }); 82 | } 83 | 84 | function checkValidServiceWorker(swUrl) { 85 | // Check if the service worker can be found. If it can't reload the page. 86 | fetch(swUrl) 87 | .then(response => { 88 | // Ensure service worker exists, and that we really are getting a JS file. 89 | if ( 90 | response.status === 404 || 91 | response.headers.get('content-type').indexOf('javascript') === -1 92 | ) { 93 | // No service worker found. Probably a different app. Reload the page. 94 | navigator.serviceWorker.ready.then(registration => { 95 | registration.unregister().then(() => { 96 | window.location.reload(); 97 | }); 98 | }); 99 | } else { 100 | // Service worker found. Proceed as normal. 101 | registerValidSW(swUrl); 102 | } 103 | }) 104 | .catch(() => { 105 | console.log( 106 | 'No internet connection found. App is running in offline mode.' 107 | ); 108 | }); 109 | } 110 | 111 | export function unregister() { 112 | if ('serviceWorker' in navigator) { 113 | navigator.serviceWorker.ready.then(registration => { 114 | registration.unregister(); 115 | }); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /app/src/components/Main.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { withStyles } from 'material-ui/styles'; 3 | import Input, { InputLabel, InputAdornment } from 'material-ui/Input'; 4 | import { FormControl, FormLabel, FormControlLabel } from 'material-ui/Form'; 5 | import Grid from 'material-ui/Grid'; 6 | import Radio, { RadioGroup } from 'material-ui/Radio'; 7 | import Paper from 'material-ui/Paper'; 8 | import Card, { CardActions, CardContent, CardMedia } from 'material-ui/Card'; 9 | import Button from 'material-ui/Button'; 10 | import axios from "axios" 11 | import Typography from 'material-ui/Typography'; 12 | import { Link } from 'react-router-dom' 13 | 14 | 15 | const styles = theme => ({ 16 | root: { 17 | flexGrow: 1, 18 | }, 19 | demo: { 20 | height: 240, 21 | }, 22 | paper: { 23 | padding: theme.spacing.unit * 2, 24 | height: '100%', 25 | }, 26 | control: { 27 | padding: theme.spacing.unit * 2, 28 | }, 29 | card: { 30 | maxWidth: 345, 31 | }, 32 | media: { 33 | height: 200, 34 | } 35 | }); 36 | 37 | const s3 = "https://s3-ap-northeast-1.amazonaws.com/manga-one"; 38 | 39 | class Main extends React.Component { 40 | 41 | constructor(props){ 42 | super(props) 43 | this.handleChange = this.handleChange.bind(this) 44 | this.state = { 45 | data: [] 46 | } 47 | this.getAll() 48 | } 49 | getAll(){ 50 | var query = { 51 | "size": 10 52 | }; 53 | axios.get("https://search-manga-image-sdozidc55hog2xc6ryonyshlja.ap-northeast-1.es.amazonaws.com/prod/image/_search", { 54 | params: { 55 | source: JSON.stringify(query), 56 | source_content_type: 'application/json' 57 | } 58 | }).then((res) => { 59 | console.log(res) 60 | console.log(res.data.hits.hits); 61 | this.setState({data :res.data.hits.hits}) 62 | }); 63 | } 64 | handleChange(event){ 65 | console.log(event.target.value) 66 | console.log("call API") 67 | var query = { 68 | "query": { 69 | "constant_score": { 70 | "filter": { 71 | "bool": { 72 | "should": [ 73 | { 74 | "term": { 75 | "tags.keyword": event.target.value 76 | } 77 | }, 78 | { 79 | "wildcard": { 80 | "plane_tags.keyword": `*${event.target.value}*` 81 | } 82 | } 83 | ] 84 | } 85 | } 86 | } 87 | } 88 | } 89 | console.log(query) 90 | axios.get("https://search-manga-image-sdozidc55hog2xc6ryonyshlja.ap-northeast-1.es.amazonaws.com/prod/image/_search", { 91 | params: { 92 | source: JSON.stringify(query), 93 | source_content_type: 'application/json' 94 | } 95 | }).then((res) => { 96 | console.log(res) 97 | console.log(res.data.hits.hits); 98 | this.setState({data :res.data.hits.hits}) 99 | }); 100 | }; 101 | 102 | 103 | render() { 104 | const { classes } = this.props; 105 | 106 | const cards = this.state.data.map(function(_data, index){ 107 | return ( 108 | 109 | 110 | 115 | 116 | 117 | 120 | 121 | 122 | 123 | 124 | ) 125 | }); 126 | return ( 127 | 128 | 129 | 135 | 136 | 139 | 140 | Search 141 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | {cards} 152 | 153 | 154 | ) 155 | 156 | } 157 | } 158 | 159 | export default withStyles(styles)(Main); 160 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 56 | 57 | 58 | 59 | cd 60 | 61 | 62 | 63 | 65 | 66 | 75 | 76 | 77 | 78 | 79 | true 80 | DEFINITION_ORDER 81 | 82 | 83 | 84 | 85 | 86 | 87 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 |